Nadzor opterećenja sustava. Na 10% vrijednosti pali se zelena LED dioda, na 50% pali se žuta, na 80% pali se crvena, na 90% sve diode se pale i gase. Pritiskom na pushbutton pali se alarmna led dioda.
https://os.mbed.com/media/uploads/nikolarp/shema_fb_thumb.jpg
Diff: main.cpp
- Revision:
- 3:6536ed4d073e
- Parent:
- 2:49f00e7e7913
diff -r 49f00e7e7913 -r 6536ed4d073e main.cpp --- a/main.cpp Mon Apr 05 17:52:54 2021 +0000 +++ b/main.cpp Thu Apr 08 12:25:44 2021 +0000 @@ -2,23 +2,25 @@ #include "IO.h" #include "SegDisplay.h" Serial pc(USBTX, USBRX); -Ticker flip; -Timer debounce; -float ADCdata; -void toggle(){ +Ticker flip; +Timer debounce; +float ADCdata; +void toggle(){ if (debounce.read_ms()>200) Alarm=!Alarm; } -void flip1(){ +void flip1(){ // crvena = !crvena; zelena = !zelena; zuta =!zuta; + wait(0.6); + flip.detach(); } int main(){ - LED(); + LED(); SegInit(); debounce.start(); -button.rise(&toggle); + button.rise(&toggle); while (1) { ADCdata=Ain; @@ -44,9 +46,7 @@ crvena=0; } else if(ADCdata>=0.9 && ADCdata<=1.0){ - flip.attach(&flip1, 0.2); - wait(0.4); - flip.detach(); + flip.attach(&flip1,0.1); } Seg1 = SegConvert(ADCdata*10); wait (0.5);