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
- Committer:
- marumbo
- Date:
- 2021-05-27
- Revision:
- 1:5ceb4255be68
- Parent:
- 0:dd0d7dbadcbd
- Child:
- 2:4eff114c7219
File content as of revision 1:5ceb4255be68:
#include "mbed.h" DigitalOut myled(LED1); DigitalIn mySwitch(p7); DigitalOut yellowLed(p5); DigitalOut redLed(p6); int switchState = 0; void BlinkYellowLed() { yellowLed =1; wait(0.5); yellowLed = 0; wait(0.5); } int main() { printf("Start program \n"); printf("Initialize yellow Led to on \n") yellowLed = 1; redLed= 0; switchState = 0; while(1) { printf("Entered Loop \n"); printf("Value of my switch %d\n", mySwitch.read()); printf("Switch state %d\n", switchState); if(mySwitch == 1) { printf("Value of my switch %d\n", mySwitch.read()); yellowLed = 0; wait(0.5); if(switchState == 0) { for(int i =0; i<5; i++) { BlinkYellowLed(); } yellowLed = 0; switchState = 1; } else { yellowLed = 0; switchState = 1; } } else { yellowLed = 1; switchState = 1; } wait_ms(500); } }