George Roussos
/
temp-blinky
Blinky with temp
Fork of random-blinky by
Revision 1:c685fdca569a, committed 2018-05-31
- Comitter:
- gkroussos
- Date:
- Thu May 31 16:08:48 2018 +0000
- Parent:
- 0:774078f45f9d
- Commit message:
- Blinks up according to temperature
Changed in this revision
img/uvision.png | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 774078f45f9d -r c685fdca569a img/uvision.png
diff -r 774078f45f9d -r c685fdca569a main.cpp --- a/main.cpp Thu May 31 15:33:24 2018 +0000 +++ b/main.cpp Thu May 31 16:08:48 2018 +0000 @@ -4,16 +4,20 @@ DigitalOut led2(LED2); DigitalOut led3(LED3); +AnalogIn LM35(P0_2); + // main() runs in its own thread in the OS // (note the calls to wait below for delays) int main() { - int myRandom; + float myTemp; + led1 = 0; + led2 = 0; + led3 = 0; while (true) { - myRandom = rand() % 100; - if (myRandom > 50) led1 = !led1; - led2 = !led2; - myRandom = rand() % 100; - if (myRandom > 50) led3 = !led3; + myTemp = ((LM35*3.3)-0.600)*100.0; + if (myTemp > 10.0) led1 = 1; + if (myTemp > 15.0) led2 = 1; + if (myTemp > 20.0) led3 = 1; wait(0.5); } }