using threads to sleep not wait

Programming the EMW3166 on the AZ3166 IOT Dev Kit using the online MBED compiler. This program show how to use thread sleep instead of wait.

Committer:
appa
Date:
Sun Dec 04 20:55:28 2022 +0000
Revision:
1:5bc12bf152c4
Parent:
0:69a64e9b0590
Last tested 12/4/2022

Who changed what in which revision?

UserRevisionLine numberNew contents of line
appa 0:69a64e9b0590 1 #include "mbed.h"
appa 0:69a64e9b0590 2 #include "platform/mbed_thread.h"
appa 1:5bc12bf152c4 3 @ last tested 12/4/2022
appa 0:69a64e9b0590 4 #define SleepTime 200
appa 0:69a64e9b0590 5
appa 0:69a64e9b0590 6 DigitalOut led1(LED1);
appa 0:69a64e9b0590 7
appa 0:69a64e9b0590 8 int main() {
appa 0:69a64e9b0590 9 while(1) {
appa 0:69a64e9b0590 10 led1 = 1;
appa 0:69a64e9b0590 11 thread_sleep_for(SleepTime);
appa 0:69a64e9b0590 12 led1 = 0;
appa 0:69a64e9b0590 13 thread_sleep_for(SleepTime);
appa 0:69a64e9b0590 14 }
appa 0:69a64e9b0590 15 }