Ljubomir Zivkovic
/
19E042PIM_T1_2019_0684
Prvi test iz Praktikuma iz mikrokontrolera - ETF 2021
Revision 0:3231ebcb290c, committed 2021-11-06
- Comitter:
- yu5eea
- Date:
- Sat Nov 06 09:28:32 2021 +0000
- Commit message:
- Prvi test iz Praktikuma iz mikrokontrolera - ETF 2021
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 06 09:28:32 2021 +0000 @@ -0,0 +1,216 @@ +// Uvoz datoteka +#include "mbed.h" + +//Definisanje direktiva i glavnih promenljivih +#define BR0 0x01 //10000 0001 +#define BR1 0x4F //10100 1111 +#define BR2 0x12 //10001 0010 +#define BR3 0x06 //10000 0110 +#define BR4 0x4C //10100 1100 +#define BR5 0x24 //10010 0100 +#define BR6 0x20 //10010 0000 +#define BR7 0x0F //10000 1111 +#define BR8 0x00 //10000 0000 +#define BR9 0x04 //10000 0100 + +// A B C D E F G +BusOut display(PB_3, PB_4, PB_5, PB_10, PA_8, PA_9, PA_10); + +DigitalOut SEL1(PB_6); +DigitalOut SEL2(PC_7); +DigitalIn SW1(PC_9); +DigitalIn SW2(PC_8); +//Pomocne funkcije + +//Glavna funkija +int main() +{ + int broj = 0; + SEL1.write(1); + SEL2.write(0); + display = BR0; + while(true) + { + + if(SW1 == 0) + { + wait_ms(100); + if(broj != 15) + { + broj++; + } + else + { + broj=0; + } + } + + if(SW2 == 0) + { + wait_ms(100); + if(broj != 0) + { + broj--; + } + else + { + broj=15; + } + } + + if(broj == 0) + { + SEL1.write(1); + SEL2.write(0); + display = BR0; + wait_ms(200); + + } + if(broj == 1) + { + SEL1.write(1); + SEL2.write(0); + display = BR1; + wait_ms(200); + } + if(broj == 2) + { + SEL1.write(1); + SEL2.write(0); + display = BR2; + wait_ms(200); + } + if(broj == 3) + { + SEL1.write(1); + SEL2.write(0); + display = BR3; + wait_ms(200); + } + if(broj == 4) + { + SEL1.write(1); + SEL2.write(0); + display = BR4; + wait_ms(200); + } + if(broj == 5) + { + SEL1.write(1); + SEL2.write(0); + display = BR5; + wait_ms(200); + } + if(broj == 6) + { + SEL1.write(1); + SEL2.write(0); + display = BR6; + wait_ms(200); + } + if(broj == 7) + { + SEL1.write(1); + SEL2.write(0); + display = BR7; + wait_ms(200); + } + if(broj == 8) + { + SEL1.write(1); + SEL2.write(0); + display = BR8; + wait_ms(200); + } + if(broj == 9) + { + SEL1.write(1); + SEL2.write(0); + display = BR9; + wait_ms(200); + } + if(broj == 10) + { + SEL1.write(0); + SEL2.write(1); + display = BR1; + wait_ms(10); + SEL1.write(1); + SEL2.write(0); + display = BR0; + wait_ms(10); + + } + if(broj == 11) + { + SEL1.write(0); + SEL2.write(1); + display = BR1; + wait_ms(10); + SEL1.write(1); + SEL2.write(0); + display = BR1; + wait_ms(10); + + } + if(broj == 12) + { + SEL1.write(0); + SEL2.write(1); + display = BR1; + wait_ms(10); + SEL1.write(1); + SEL2.write(0); + display = BR2; + wait_ms(10); + + } + if(broj == 13) + { + SEL1.write(0); + SEL2.write(1); + display = BR1; + wait_ms(10); + SEL1.write(1); + SEL2.write(0); + display = BR3; + wait_ms(10); + + } + if(broj == 14) + { + SEL1.write(0); + SEL2.write(1); + display = BR1; + wait_ms(10); + SEL1.write(1); + SEL2.write(0); + display = BR4; + wait_ms(10); + + } + if(broj == 15) + { + SEL1.write(0); + SEL2.write(1); + display = BR1; + wait_ms(10); + SEL1.write(1); + SEL2.write(0); + display = BR5; + wait_ms(10); + + } + + + + + + + + + + + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 06 09:28:32 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file