![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Pavle Popovic 2020/0494
Dependencies: Adafruit_GFX 19E042PIM_MB_PINS
Diff: main2.txt
- Revision:
- 0:4b068ef5ed41
diff -r 000000000000 -r 4b068ef5ed41 main2.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main2.txt Mon Jan 17 16:05:55 2022 +0000 @@ -0,0 +1,59 @@ +/* mbed Microcontroller Library + * Copyright (c) 2019 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "mbed.h"//uvoz biblioteka + +#define SCALER 4950//definisanje direktiva + +AnalogIn pot1(PA_0);//glavne promenljive +AnalogIn pot2(PA_1); +PwmOut buzz(PA_11); +InterruptIn sw1(PC_9); +BusOut display(PA_10,PA_9,PA_8,PB_10,PB_5,PB_4,PB_3,PA_5); +DigitalOut SEL2(PC_7); +DigitalOut SEL1(PB_6); + +void ISR_sw1(void);//pomocne funkcije + +int main()//glavna funkcija +{ + buzz.period_ms(1); + sw1.fall(&ISR_sw1); + while (true) { + buzz.period_us(pot2.read()*SCALER+50); + buzz.write(pot1.read()); + wait_ms(1); + } +} + +void ISR_sw1()//interrupt sub-routine +{ + int i=pot1.read()*100; + + int d; + d=i/10; + while(!sw1.read()) + { + SEL1.write(1); + SEL2.write(0); + switch(d) + { + case 0:display.write(0xC0);break; + case 1:display.write(0xF9);break; + case 2:display.write(0xA4);break; + case 3:display.write(0xB0);break; + case 4:display.write(0x99);break; + case 5:display.write(0x92);break; + case 6:display.write(0x82);break; + case 7:display.write(0xF8);break; + case 8:display.write(0x80);break; + case 9:display.write(0x90);break; + } + wait_us(500); + SEL2.write(1); + } + + +}