![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mihajlo Djordjevic 2020/0438
main.cpp
- Committer:
- mixidj
- Date:
- 2021-11-13
- Revision:
- 0:849fcc3d83a1
File content as of revision 0:849fcc3d83a1:
// Mihajlo Djordjevic 2020/0438 // Uvoz biblioteke #include "mbed.h" //Makro #define POLLING_PERIOD 20 #define MAX_POT1 0.9f #define MAX_POT2 0.8f #define MAX_PERIOD 1.05 // Glavne promenljive PwmOut buzzer(PA_11); AnalogIn pot1(PA_0); AnalogIn pot2(PA_1); InterruptIn button(PC_9); // Funkcije void ISR_procenat(void); int main () { while(true) { button.fall(ISR_procenat); if(pot1.read() < MAX_POT1){ buzzer = pot1.read(); } else buzzer = MAX_POT1; printf(" pot1 : %1.2f pot2 : %1.2f \r", pot1.read(),pot2.read()); float period; if(pot2.read() < MAX_POT2){ period = 5 - pot2.read() * 4.95; buzzer.period_ms(period); } else buzzer.period_ms(MAX_PERIOD); wait_ms(POLLING_PERIOD); } } void ISR_procenat(){ }