![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ping pong projekt
Dependencies: interupt mbed resetpolja pozicijaLoptice resetALL Ispis PozicijaOdbijaca
projekt je izveden s 8x8 led matricom na kojoj se igra ping pon pomoću potenciometara.
main.cpp@0:e7d047a7fe29, 2021-02-22 (annotated)
- Committer:
- atopcic
- Date:
- Mon Feb 22 08:33:54 2021 +0000
- Revision:
- 0:e7d047a7fe29
datoteka
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
atopcic | 0:e7d047a7fe29 | 1 | #include "mbed.h" |
atopcic | 0:e7d047a7fe29 | 2 | #include "resetpolja.h" |
atopcic | 0:e7d047a7fe29 | 3 | #include "Ispis.h" |
atopcic | 0:e7d047a7fe29 | 4 | #include "PozicijaOdbijaca.h" |
atopcic | 0:e7d047a7fe29 | 5 | #include "pozicijaLoptice.h" |
atopcic | 0:e7d047a7fe29 | 6 | #include "reset_polja.h" |
atopcic | 0:e7d047a7fe29 | 7 | #include "Interupt.h" |
atopcic | 0:e7d047a7fe29 | 8 | |
atopcic | 0:e7d047a7fe29 | 9 | extern int polje[8][8]; |
atopcic | 0:e7d047a7fe29 | 10 | extern int StartStop; |
atopcic | 0:e7d047a7fe29 | 11 | extern Timer timer1,timer3,debounce; |
atopcic | 0:e7d047a7fe29 | 12 | Timer timer2; |
atopcic | 0:e7d047a7fe29 | 13 | extern InterruptIn button; |
atopcic | 0:e7d047a7fe29 | 14 | |
atopcic | 0:e7d047a7fe29 | 15 | void ispis(void); |
atopcic | 0:e7d047a7fe29 | 16 | void pozicija_odbijaca(void); |
atopcic | 0:e7d047a7fe29 | 17 | void PozicijaLoptice (void); |
atopcic | 0:e7d047a7fe29 | 18 | void ResetPoljaLoptice (void); |
atopcic | 0:e7d047a7fe29 | 19 | void ResetPolja (void); |
atopcic | 0:e7d047a7fe29 | 20 | void toggle(void); |
atopcic | 0:e7d047a7fe29 | 21 | |
atopcic | 0:e7d047a7fe29 | 22 | int main() |
atopcic | 0:e7d047a7fe29 | 23 | { |
atopcic | 0:e7d047a7fe29 | 24 | L8=0; L9=0; L10=0; L11=0; L12=0; L13=0; L14=0; L15=0; G1=0; G2=0; G3=0; |
atopcic | 0:e7d047a7fe29 | 25 | timer1.start(); // start timer counting |
atopcic | 0:e7d047a7fe29 | 26 | timer2.start(); |
atopcic | 0:e7d047a7fe29 | 27 | timer3.start(); |
atopcic | 0:e7d047a7fe29 | 28 | |
atopcic | 0:e7d047a7fe29 | 29 | while(1) { |
atopcic | 0:e7d047a7fe29 | 30 | |
atopcic | 0:e7d047a7fe29 | 31 | if(timer2.read_ms() >= 400){ |
atopcic | 0:e7d047a7fe29 | 32 | ResetPoljaLoptice(); |
atopcic | 0:e7d047a7fe29 | 33 | PozicijaLoptice(); |
atopcic | 0:e7d047a7fe29 | 34 | timer2.reset(); |
atopcic | 0:e7d047a7fe29 | 35 | timer3.reset(); |
atopcic | 0:e7d047a7fe29 | 36 | } |
atopcic | 0:e7d047a7fe29 | 37 | |
atopcic | 0:e7d047a7fe29 | 38 | pozicija_odbijaca(); |
atopcic | 0:e7d047a7fe29 | 39 | ispis(); |
atopcic | 0:e7d047a7fe29 | 40 | debounce.start(); |
atopcic | 0:e7d047a7fe29 | 41 | button.rise(&toggle); |
atopcic | 0:e7d047a7fe29 | 42 | while(StartStop==0){ResetPolja(); ispis();} |
atopcic | 0:e7d047a7fe29 | 43 | } |
atopcic | 0:e7d047a7fe29 | 44 | } |
atopcic | 0:e7d047a7fe29 | 45 | |
atopcic | 0:e7d047a7fe29 | 46 | |
atopcic | 0:e7d047a7fe29 | 47 | |
atopcic | 0:e7d047a7fe29 | 48 | |
atopcic | 0:e7d047a7fe29 | 49 | |
atopcic | 0:e7d047a7fe29 | 50 |