![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Semafor
main.cpp
- Committer:
- zradic
- Date:
- 23 months ago
- Revision:
- 0:bcbee14067e6
- Child:
- 1:f929a0c362e7
File content as of revision 0:bcbee14067e6:
#include "mbed.h" #include "svijetlasemafora.h" class Pjesaci { public: Pjesaci(PinName pin) : led(pin) { led = 0; } void flip() { if(crveniLed==1){ led = !led; } else{ led=0; } } private: DigitalOut led; }; InterruptIn tipkalo(D7); Pjesaci pjesaciLed(LED1); Ticker t; void prekid(void){ if(zeleniLed==1){ pomocna=1; } } int main() { t.attach(callback(&pjesaciLed, &Pjesaci::flip), 0.5); tipkalo.mode(PullUp); tipkalo.fall(&prekid); while (true) { if(brojac==0){ crveno(10000); } if(brojac==1){ crvenozuto(2000); } if(brojac==2){ zeleno(7000); } if(brojac==3){ zuto(3000); } thread_sleep_for(10); } }