QT Chan
/
Nucleo_read_button
Button control led blink
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalIn mybutton(USER_BUTTON); 00004 DigitalOut myled(LED1); 00005 00006 int main() { 00007 while(1) { 00008 if (mybutton == 0) { // Button is pressed 00009 myled = !myled; // Toggle the LED state 00010 wait(0.1); // 100 ms 00011 } 00012 else { 00013 myled = 1; // LED is ON 00014 wait(0.2); // 200 ms 00015 myled = 0; // LED is OFF 00016 wait(1.0); // 1 sec 00017 } 00018 } 00019 } 00020
Generated on Mon Jul 18 2022 22:16:48 by 1.7.2