Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 // run some code based on switching a switch (changing a pin state) 00002 00003 #include "mbed.h" 00004 00005 DigitalIn toggle(p5); 00006 DigitalOut myled(LED1); 00007 00008 void toggle_on() { 00009 for(int i=0; i<10; i++) { 00010 myled = !myled; 00011 wait(0.2); 00012 } 00013 } 00014 00015 void toggle_off() { 00016 // do nothing 00017 } 00018 00019 int main() { 00020 while(1) { 00021 while(!toggle); // wait while toggle == 0 00022 toggle_on(); 00023 while(toggle); // wait while toggle == 1 00024 toggle_off(); 00025 } 00026 }
Generated on Tue Jul 12 2022 13:21:54 by
