Blink LEDs by using a PortOut object

Dependencies:   mbed

main.cpp

Committer:
cspista
Date:
2021-09-21
Revision:
0:e85a195c110f

File content as of revision 0:e85a195c110f:

#include "mbed.h"

#define LED_MASK     0x00000038   //bits 3, 4, 5
#define RED_MASK     0x00000008   //bit 3 (D3): LED_RED
#define GREEN_MASK   0x00000010   //bit 5 (D4): LED_GREEN
#define BLUE_MASK    0x00000020   //bit 4 (D5): LED_BLUE

PortOut ledport(PortB, LED_MASK);

int main()
{
    while(1) {
        ledport = RED_MASK;
        wait(0.5);
        ledport = GREEN_MASK;
        wait(0.5);
        ledport = BLUE_MASK;
        wait(0.5);
        ledport = LED_MASK;
        wait(0.5);        
    }
}