Milan Takic
/
19E042PIM_T1_2020_0690
Milan Takic 2020/0690 sedmosegmentni displej
Revision 0:926a55324bcc, committed 2021-11-06
- Comitter:
- milant
- Date:
- Sat Nov 06 09:28:19 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 |
diff -r 000000000000 -r 926a55324bcc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 06 09:28:19 2021 +0000 @@ -0,0 +1,89 @@ +// uvoz biblioteke + +#include "mbed.h" + +// definisanje direktiva + +#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 SW1(PC_9) +#define SW2(PC_8) + +// kreiranje objekata + +const int digit[] = {0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010, 0b0000010, 0b1111000, 0b0000000, 0b0010000}; +BusOut display(A,B,C,D,E,F,G,SEL_1,SEL_2); +DigitalOut d1(SEL_1); +DigitalOut d2(SEL_2); +DigitalIn sw1(PC_9); +DigitalIn sw2(PC_8); + +// glavna funkcija + +int main(){ + + //incijalizovanje promenljivih + + static char button1_released = 0; + static char button2_released = 0; + d1.write(1); + d2.write(0); + display = digit[0]; + int i =-1; + + // glavna petlja + + while(true){ + + if(!sw2){ + if(button2_released){ + + if(i == -1){ + i = 9; + } + display = digit[i--]; + button2_released = 0; + } + } + else{ + button2_released = 1; + } + wait_ms(50); + + if(!sw1){ + if(button1_released){ + + if(i == 10 ){ + i = -1; + } + display = digit[i++]; + button1_released = 0; + } + } + else{ + button1_released = 1; + } + wait_ms(50); + } +} + + +//imao sam problem gde su se oba displeja palila iako sam na pocetku prvi stavio na 1 drugi na 0 + + //cisto da probam + /*while(true){ + if(i == 9){ + i = -1; + } + display = digit[++i]; + + wait_ms(1000); + } + */
diff -r 000000000000 -r 926a55324bcc mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 06 09:28:19 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file