Ognjen Arbutina 2020/0581

Dependencies:   mbed

Committer:
arbutinao
Date:
Sat Nov 13 08:48:27 2021 +0000
Revision:
0:7ebdc53b1d02
Ognjen Arbutina 2020/0581

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arbutinao 0:7ebdc53b1d02 1 /*
arbutinao 0:7ebdc53b1d02 2 * Prikazana vrednost na displeju ne pokazuje ono sto se moze cuti. To se desava zbog razlicitih stanja na potenciometru koja se desavaju usled pritiska na taster SW1.
arbutinao 0:7ebdc53b1d02 3 */
arbutinao 0:7ebdc53b1d02 4
arbutinao 0:7ebdc53b1d02 5 // Biblioteke za uvoz
arbutinao 0:7ebdc53b1d02 6
arbutinao 0:7ebdc53b1d02 7 #include "mbed.h"
arbutinao 0:7ebdc53b1d02 8
arbutinao 0:7ebdc53b1d02 9 // Definisanje makroa
arbutinao 0:7ebdc53b1d02 10
arbutinao 0:7ebdc53b1d02 11 #define PERIOD_1 5
arbutinao 0:7ebdc53b1d02 12 #define SCALE 100
arbutinao 0:7ebdc53b1d02 13 #define ZERO 0
arbutinao 0:7ebdc53b1d02 14
arbutinao 0:7ebdc53b1d02 15 // Globalne promenljive
arbutinao 0:7ebdc53b1d02 16
arbutinao 0:7ebdc53b1d02 17 AnalogIn pot1(PA_0);
arbutinao 0:7ebdc53b1d02 18 AnalogIn pot2(PA_1);
arbutinao 0:7ebdc53b1d02 19 PwmOut buzzer(PA_11);
arbutinao 0:7ebdc53b1d02 20 InterruptIn sw1(PC_9);
arbutinao 0:7ebdc53b1d02 21
arbutinao 0:7ebdc53b1d02 22 // Deklaracija funkcija
arbutinao 0:7ebdc53b1d02 23
arbutinao 0:7ebdc53b1d02 24 void ISR_sw1(void);
arbutinao 0:7ebdc53b1d02 25 void screenMux(void);
arbutinao 0:7ebdc53b1d02 26
arbutinao 0:7ebdc53b1d02 27 // Glavna funkcija
arbutinao 0:7ebdc53b1d02 28
arbutinao 0:7ebdc53b1d02 29 int main()
arbutinao 0:7ebdc53b1d02 30 {
arbutinao 0:7ebdc53b1d02 31 // Zadatak 2
arbutinao 0:7ebdc53b1d02 32 if (pot2.read() == ZERO)
arbutinao 0:7ebdc53b1d02 33 {
arbutinao 0:7ebdc53b1d02 34 buzzer.period_ms(PERIOD_1));
arbutinao 0:7ebdc53b1d02 35 }
arbutinao 0:7ebdc53b1d02 36 else
arbutinao 0:7ebdc53b1d02 37 {
arbutinao 0:7ebdc53b1d02 38 buzzer.period_ms(PERIOD_1 / pot2.read() * SCALE);
arbutinao 0:7ebdc53b1d02 39 }
arbutinao 0:7ebdc53b1d02 40
arbutinao 0:7ebdc53b1d02 41 // Zadatak 1
arbutinao 0:7ebdc53b1d02 42
arbutinao 0:7ebdc53b1d02 43 buzzer.write(pot1.read());
arbutinao 0:7ebdc53b1d02 44
arbutinao 0:7ebdc53b1d02 45 sw1.fall(&ISR_sw1);
arbutinao 0:7ebdc53b1d02 46 while(1);
arbutinao 0:7ebdc53b1d02 47
arbutinao 0:7ebdc53b1d02 48 }
arbutinao 0:7ebdc53b1d02 49
arbutinao 0:7ebdc53b1d02 50 void ISR_sw1 ()
arbutinao 0:7ebdc53b1d02 51 {
arbutinao 0:7ebdc53b1d02 52 screenMux();
arbutinao 0:7ebdc53b1d02 53 }
arbutinao 0:7ebdc53b1d02 54
arbutinao 0:7ebdc53b1d02 55 void screenMux()
arbutinao 0:7ebdc53b1d02 56 {
arbutinao 0:7ebdc53b1d02 57
arbutinao 0:7ebdc53b1d02 58 }