Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PWM_Tone_Library mbed microbit
main.cpp
00001 #include "mbed.h" 00002 #include "pwm_tone.h" 00003 #include "MicroBit.h" 00004 00005 MicroBit uBit; 00006 PwmOut Buzzer(MICROBIT_PIN_P0); 00007 float c_2 = 1000000/523; 00008 double sensori = 0; 00009 double lampotila = 0; 00010 00011 double muunna_lampotilaksi(double arvo){ 00012 return ((arvo * 3) / 1024 - 0.5) * 100; 00013 } 00014 00015 int main(){ 00016 uBit.init(); 00017 while (1){ 00018 sensori = uBit.io.P1.getAnalogValue(); 00019 lampotila = muunna_lampotilaksi(sensori); 00020 if(lampotila <= 30){ 00021 Stop_tunes(Buzzer); 00022 } else{ 00023 Tune(Buzzer, c_2, 8); 00024 wait_ms(250); 00025 } 00026 } 00027 }
Generated on Fri Jul 22 2022 20:02:56 by
1.7.2