![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Drugi test iz PIM-a Milan Takic 2020/0690
Revision 0:208b1e7384da, committed 2021-11-13
- Comitter:
- milant
- Date:
- Sat Nov 13 08:51:20 2021 +0000
- Commit message:
- Milan Takic 2020/0690
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 13 08:51:20 2021 +0000 @@ -0,0 +1,71 @@ +/* +Drugi test iz PIM-a +Milan Takic 2020/0690 +13.11.2021 +*/ + +//uvezivanje biblioteka +#include "mbed.h" + +//definisanje makroa +#define A PA_10 +#define B PA_9 +#define C PA_8 +#define D PB_10 +#define E PB_5 +#define F PB_4 +#define G PB_3 +#define SEL_1 PB_6 +#define SEL_2 PC_7 +#define PWM_PERIOD 15 +#define V_MULTIPLIER 3.3f +#define DUTY_CYCLE 0.5f +#define MULTIPLIER 5 + +//globalne promenljive + +BusOut display(A,B,C,D,E,F,G); +DigitalOut select1(SEL_1); +DigitalOut select2(SEL_2); +AnalogIn pot1 (PA_0); +AnalogIn pot2 (PA_1); +InterruptIn sw1(PC_9); +PwmOut buzzer(PA_11); +const int digit[] = {0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000}; +int i = 0; +int j = 0; +int flag = 0; + +//deklaracija funkcija +void ISR_sw1(); +//glavna funkcija +int main(){ + select1.write(1); + select2.write(1); + sw1.fall(&ISR_sw1); + buzzer.period_ms(PWM_PERIOD); + + while(true){ + buzzer.write(pot1.read()); + i = pot1.read()*10; + j = pot1.read()*10; + if(flag){ + select2.write(1); + select1.write(0); + display = digit[i]; + wait_us(100); + select1.write(1); + select2.write(0); + display = digit[j]; + wait_us(100); + flag = 0; + } + } + +} + +void ISR_sw1(){ + flag = 1; +} + +// :( \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 13 08:51:20 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file