Masa Kovacevic
/
19E042PIM_T1_2020_0229
Masa Kovacevic 2020/0229
main.cpp@0:3d56342443d5, 2021-11-06 (annotated)
- Committer:
- km200229d
- Date:
- Sat Nov 06 09:25:00 2021 +0000
- Revision:
- 0:3d56342443d5
- Child:
- 1:48c498f48efd
Masa Kovacevic 2020/0229
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
km200229d | 0:3d56342443d5 | 1 | |
km200229d | 0:3d56342443d5 | 2 | /* |
km200229d | 0:3d56342443d5 | 3 | * Biblioteke za uvoz: |
km200229d | 0:3d56342443d5 | 4 | */ |
km200229d | 0:3d56342443d5 | 5 | #include "mbed.h" |
km200229d | 0:3d56342443d5 | 6 | |
km200229d | 0:3d56342443d5 | 7 | /* |
km200229d | 0:3d56342443d5 | 8 | * Definisanje makroa: |
km200229d | 0:3d56342443d5 | 9 | */ |
km200229d | 0:3d56342443d5 | 10 | |
km200229d | 0:3d56342443d5 | 11 | /* |
km200229d | 0:3d56342443d5 | 12 | * Globalne promenljive: |
km200229d | 0:3d56342443d5 | 13 | */ |
km200229d | 0:3d56342443d5 | 14 | BusOut display(PA_10,PA_9,PA_8,PB_10,PB_5,PB_4,PB_3,PA_5); |
km200229d | 0:3d56342443d5 | 15 | |
km200229d | 0:3d56342443d5 | 16 | DigitalOut SEL2(PC_7); |
km200229d | 0:3d56342443d5 | 17 | DigitalOut SEL1(PB_6); |
km200229d | 0:3d56342443d5 | 18 | DigitalIn SW1(PC_9); |
km200229d | 0:3d56342443d5 | 19 | |
km200229d | 0:3d56342443d5 | 20 | /* |
km200229d | 0:3d56342443d5 | 21 | * Deklaracija funkcija: |
km200229d | 0:3d56342443d5 | 22 | */ |
km200229d | 0:3d56342443d5 | 23 | void Funkcija2 (void); //funkcija za digit 1 |
km200229d | 0:3d56342443d5 | 24 | void Funkcija1 (void); //funkcija za digit 2 |
km200229d | 0:3d56342443d5 | 25 | void Funkcija0 (void); //funkcija kada elim da mi digit 1 bude 0 |
km200229d | 0:3d56342443d5 | 26 | /* |
km200229d | 0:3d56342443d5 | 27 | * Glavna funkcija: |
km200229d | 0:3d56342443d5 | 28 | */ |
km200229d | 0:3d56342443d5 | 29 | int main() |
km200229d | 0:3d56342443d5 | 30 | { |
km200229d | 0:3d56342443d5 | 31 | static char ButtonReleased = 0; |
km200229d | 0:3d56342443d5 | 32 | int i = 0; //promenljiva kjom brojim da li |
km200229d | 0:3d56342443d5 | 33 | int k = 0; |
km200229d | 0:3d56342443d5 | 34 | |
km200229d | 0:3d56342443d5 | 35 | while(true) |
km200229d | 0:3d56342443d5 | 36 | { |
km200229d | 0:3d56342443d5 | 37 | |
km200229d | 0:3d56342443d5 | 38 | while (i <= 9){ |
km200229d | 0:3d56342443d5 | 39 | if (!SW1) |
km200229d | 0:3d56342443d5 | 40 | { |
km200229d | 0:3d56342443d5 | 41 | if ( ButtonReleased){ |
km200229d | 0:3d56342443d5 | 42 | Funkcija2(); |
km200229d | 0:3d56342443d5 | 43 | ButtonReleased = 0; |
km200229d | 0:3d56342443d5 | 44 | } |
km200229d | 0:3d56342443d5 | 45 | else |
km200229d | 0:3d56342443d5 | 46 | { |
km200229d | 0:3d56342443d5 | 47 | ButtonReleased = 1; |
km200229d | 0:3d56342443d5 | 48 | } |
km200229d | 0:3d56342443d5 | 49 | wait_ms(50); |
km200229d | 0:3d56342443d5 | 50 | i = i+1; |
km200229d | 0:3d56342443d5 | 51 | } |
km200229d | 0:3d56342443d5 | 52 | |
km200229d | 0:3d56342443d5 | 53 | |
km200229d | 0:3d56342443d5 | 54 | while (k < = 5){ |
km200229d | 0:3d56342443d5 | 55 | if (!SW1) |
km200229d | 0:3d56342443d5 | 56 | { |
km200229d | 0:3d56342443d5 | 57 | if ( ButtonReleased) |
km200229d | 0:3d56342443d5 | 58 | { |
km200229d | 0:3d56342443d5 | 59 | Funkcija2(); |
km200229d | 0:3d56342443d5 | 60 | Funkcija1(); |
km200229d | 0:3d56342443d5 | 61 | ButtonReleased = 0; |
km200229d | 0:3d56342443d5 | 62 | } |
km200229d | 0:3d56342443d5 | 63 | |
km200229d | 0:3d56342443d5 | 64 | |
km200229d | 0:3d56342443d5 | 65 | else |
km200229d | 0:3d56342443d5 | 66 | { |
km200229d | 0:3d56342443d5 | 67 | ButtonReleased = 1; |
km200229d | 0:3d56342443d5 | 68 | } |
km200229d | 0:3d56342443d5 | 69 | |
km200229d | 0:3d56342443d5 | 70 | wait_ms(50); |
km200229d | 0:3d56342443d5 | 71 | k = k+1; |
km200229d | 0:3d56342443d5 | 72 | } |
km200229d | 0:3d56342443d5 | 73 | } |
km200229d | 0:3d56342443d5 | 74 | |
km200229d | 0:3d56342443d5 | 75 | /* |
km200229d | 0:3d56342443d5 | 76 | * Definicija funkcija: |
km200229d | 0:3d56342443d5 | 77 | */ |
km200229d | 0:3d56342443d5 | 78 | |
km200229d | 0:3d56342443d5 | 79 | void Funkcija2 (){ |
km200229d | 0:3d56342443d5 | 80 | |
km200229d | 0:3d56342443d5 | 81 | SEL2.write(0); |
km200229d | 0:3d56342443d5 | 82 | display = display.read() + 1; |
km200229d | 0:3d56342443d5 | 83 | wait_ms(15); |
km200229d | 0:3d56342443d5 | 84 | SEL2.write(1); |
km200229d | 0:3d56342443d5 | 85 | |
km200229d | 0:3d56342443d5 | 86 | } |
km200229d | 0:3d56342443d5 | 87 | |
km200229d | 0:3d56342443d5 | 88 | |
km200229d | 0:3d56342443d5 | 89 | void Funkcija1 (){ |
km200229d | 0:3d56342443d5 | 90 | |
km200229d | 0:3d56342443d5 | 91 | SEL1.write(0); |
km200229d | 0:3d56342443d5 | 92 | display = i; |
km200229d | 0:3d56342443d5 | 93 | wait_ms(15); |
km200229d | 0:3d56342443d5 | 94 | SEL1.write(1); |
km200229d | 0:3d56342443d5 | 95 | } |
km200229d | 0:3d56342443d5 | 96 | |
km200229d | 0:3d56342443d5 | 97 | void Funkcija0(){ |
km200229d | 0:3d56342443d5 | 98 | SEL2.write(0); |
km200229d | 0:3d56342443d5 | 99 | display = 0; |
km200229d | 0:3d56342443d5 | 100 | wait_ms(15); |
km200229d | 0:3d56342443d5 | 101 | SEL2.write(1); |
km200229d | 0:3d56342443d5 | 102 | } |