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.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut red_led(D7); 00004 DigitalOut yellow_led(D6); 00005 DigitalOut green_led(D5); 00006 DigitalIn SW1(D4); 00007 00008 //This is the solution based on the proposed flowchart. 00009 //It is flawed however (see next exercise) due to 00010 //switch bounce. 00011 00012 int main() { 00013 00014 //Switch on Yellow and Green to indicate 00015 //that the code is running 00016 yellow_led = 1; 00017 green_led = 1; 00018 red_led = 0; //Set RED LED to OFF 00019 00020 // Wait for SW1 to be pressed 00021 while (SW1 == 0) { } 00022 00023 // Wait for SW1 to be released 00024 while (SW1 == 1) { } 00025 00026 red_led = 1; //Turn ON LED 00027 00028 while (1) { } //Repeat forever 00029 }
Generated on Fri Jul 15 2022 01:36:39 by
1.7.2