Vjezba 2 iz PURSA.
Dependencies: mbed
digitalni_ulaz_pullNone.cpp
- Committer:
- JosipLupinski
- Date:
- 2016-10-26
- Revision:
- 0:0f35d76ae855
File content as of revision 0:0f35d76ae855:
#include "mbed.h" DigitalOut green(p5); DigitalOut red(p6); DigitalIn switchInput(p10); int main() { int switchState; switchInput.mode(PullNone); //Bog zna kaj bu, nepredvidivo se ponaša while(true) { switchState = switchInput; // citanje stanja ulaza samo jednom u prolazu petlje if(switchState == 0) { green = 0; red = 1; wait(0.5); red = 0; wait(0.5); } else if (switchState == 1) { red = 0; green = 1; wait(0.5); green = 0; wait(0.5); } else { // nemoguc slucaj red = 1; green = 1; } } }