IOT assignment 4 exercise 1

Dependencies:   mbed

main.cpp

Committer:
mcalzana
Date:
6 months ago
Revision:
1:2eeb35548179
Parent:
0:d9ec23dd131e

File content as of revision 1:2eeb35548179:

#include "mbed.h"

Ticker toggle_led_ticker;
Serial pc(USBTX, USBRX);

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);

int counter = 0;

void toggle_led() {
    int bit1 = counter & 1;
    int bit2 = counter & 2;
    int bit3 = counter & 4;
    led1 = bit1;
    led2 = bit2;
    led3 = bit3;
    counter++;
}

int main() {
    toggle_led_ticker.attach(&toggle_led, 1);
}