Lämpötilavahti micro:bitille Temperature alarm for micro:bit
Dependencies: PWM_Tone_Library mbed microbit
Revision 0:a4d4d30ab997, committed 2018-07-24
- Comitter:
- tyynetyyne
- Date:
- Tue Jul 24 16:44:13 2018 +0000
- Commit message:
- First version of temperature alarm
Changed in this revision
diff -r 000000000000 -r a4d4d30ab997 PWM_Tone_Library.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PWM_Tone_Library.lib Tue Jul 24 16:44:13 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/justinkim/code/PWM_Tone_Library/#4b841d62e529
diff -r 000000000000 -r a4d4d30ab997 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jul 24 16:44:13 2018 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "pwm_tone.h" +#include "MicroBit.h" + +MicroBit uBit; +PwmOut Buzzer(MICROBIT_PIN_P0); +float c_2 = 1000000/523; +double sensori = 0; +double lampotila = 0; + +double muunna_lampotilaksi(double arvo){ + return ((arvo * 3) / 1024 - 0.5) * 100; +} + +int main(){ + uBit.init(); + while (1){ + sensori = uBit.io.P1.getAnalogValue(); + lampotila = muunna_lampotilaksi(sensori); + if(lampotila <= 30){ + Stop_tunes(Buzzer); + } else{ + Tune(Buzzer, c_2, 8); + wait_ms(250); + } + } +} \ No newline at end of file
diff -r 000000000000 -r a4d4d30ab997 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jul 24 16:44:13 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/bad568076d81 \ No newline at end of file
diff -r 000000000000 -r a4d4d30ab997 microbit.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/microbit.lib Tue Jul 24 16:44:13 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/Lancaster-University/code/microbit/#4b89e7e3494f