Template for Demo Program

Committer:
bjbance
Date:
Fri Mar 12 01:50:05 2021 +0000
Revision:
3:cfad8ca57114
Parent:
1:82e519677f1a
Updated MBED OS Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bjbance 0:bf54a250aa28 1 #include "mbed.h"
bjbance 0:bf54a250aa28 2 #include "ThisThread.h"
bjbance 0:bf54a250aa28 3
bjbance 0:bf54a250aa28 4 DigitalOut rLED(LED1);
bjbance 0:bf54a250aa28 5 DigitalOut gLED(LED2);
bjbance 0:bf54a250aa28 6
bjbance 0:bf54a250aa28 7 // main() runs in its own thread in the OS
bjbance 0:bf54a250aa28 8 // (note the calls to Thread::wait below for delays)
bjbance 0:bf54a250aa28 9 int main()
bjbance 0:bf54a250aa28 10 {
bjbance 0:bf54a250aa28 11 gLED = LED_ON;
bjbance 0:bf54a250aa28 12 rLED = LED_ON;
bjbance 0:bf54a250aa28 13
bjbance 0:bf54a250aa28 14 ThisThread::sleep_for(1000ms);
bjbance 0:bf54a250aa28 15 rLED = LED_OFF;
bjbance 0:bf54a250aa28 16
bjbance 0:bf54a250aa28 17 while (true) {
bjbance 0:bf54a250aa28 18 gLED = !gLED;
bjbance 0:bf54a250aa28 19 ThisThread::sleep_for(500ms);
bjbance 0:bf54a250aa28 20 }
bjbance 0:bf54a250aa28 21 }
bjbance 0:bf54a250aa28 22