Lazar Dobric
/
Zadatak_2_5
samo jak gas
Revision 0:14719bc34055, committed 2021-11-13
- Comitter:
- makotolagano
- Date:
- Sat Nov 13 07:05:29 2021 +0000
- Commit message:
- najjaci gas;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 14719bc34055 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 13 07:05:29 2021 +0000 @@ -0,0 +1,65 @@ +/* + +Lazar Dobric 11/12/2021 23:12 EST + +*/ + + +// importing libraries +#include "mbed.h" + + +// macros +#define VOLTAGE_SCALER 3.3f +#define VOLTAGE_LIMIT 2.7f +#define PWM_PERIOD_MS 1 +#define BUZZER_HIGH 0.9f +#define BUZZER_LOW 0 + + +AnalogIn pot2(PA_1); +PwmOut buzzer(PA_11); +InterruptIn sw1(PC_9); + +// global +static char buzzing = 0; + +// declarations +void ISR_sw1(void); + +int main() +{ + + buzzer.period_ms(PWM_PERIOD_MS); + buzzer.write(BUZZER_LOW); + sw1.fall(&ISR_sw1); + + while(true) + { + if(pot2.read()*VOLTAGE_SCALER >= VOLTAGE_LIMIT) + { + if (!buzzing) + { + buzzer.write(BUZZER_HIGH); + buzzing = 1; + } + } + else + { + buzzing = 0; + } + + + } + +} + +// Interrupt Service Routine +void ISR_sw1(void) +{ + buzzer.write(BUZZER_LOW); + buzzing = 0; + +} + +
diff -r 000000000000 -r 14719bc34055 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 13 07:05:29 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file