Blink LEDs by using a PortOut object

Dependencies:   mbed

Committer:
cspista
Date:
Tue Sep 21 16:42:03 2021 +0000
Revision:
0:e85a195c110f
MBED 2 project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cspista 0:e85a195c110f 1 #include "mbed.h"
cspista 0:e85a195c110f 2
cspista 0:e85a195c110f 3 #define LED_MASK 0x00000038 //bits 3, 4, 5
cspista 0:e85a195c110f 4 #define RED_MASK 0x00000008 //bit 3 (D3): LED_RED
cspista 0:e85a195c110f 5 #define GREEN_MASK 0x00000010 //bit 5 (D4): LED_GREEN
cspista 0:e85a195c110f 6 #define BLUE_MASK 0x00000020 //bit 4 (D5): LED_BLUE
cspista 0:e85a195c110f 7
cspista 0:e85a195c110f 8 PortOut ledport(PortB, LED_MASK);
cspista 0:e85a195c110f 9
cspista 0:e85a195c110f 10 int main()
cspista 0:e85a195c110f 11 {
cspista 0:e85a195c110f 12 while(1) {
cspista 0:e85a195c110f 13 ledport = RED_MASK;
cspista 0:e85a195c110f 14 wait(0.5);
cspista 0:e85a195c110f 15 ledport = GREEN_MASK;
cspista 0:e85a195c110f 16 wait(0.5);
cspista 0:e85a195c110f 17 ledport = BLUE_MASK;
cspista 0:e85a195c110f 18 wait(0.5);
cspista 0:e85a195c110f 19 ledport = LED_MASK;
cspista 0:e85a195c110f 20 wait(0.5);
cspista 0:e85a195c110f 21 }
cspista 0:e85a195c110f 22 }