![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Milan Takic 2020/0690 sedmosegmentni displej
main.cpp
- Committer:
- milant
- Date:
- 2021-11-06
- Revision:
- 0:926a55324bcc
File content as of revision 0:926a55324bcc:
// 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); } */