Marko Marinović
/
Konstrukcijski_LAMPICE
Konstrukcijski rad
main.cpp@0:89c243df8710, 2021-05-06 (annotated)
- Committer:
- kurton_ing
- Date:
- Thu May 06 19:27:34 2021 +0000
- Revision:
- 0:89c243df8710
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kurton_ing | 0:89c243df8710 | 1 | #include "mbed.h" |
kurton_ing | 0:89c243df8710 | 2 | #include "LAMPICE.h" |
kurton_ing | 0:89c243df8710 | 3 | LAMPICE LED(PC_8, PC_6, PC_5, PA_12, PC_9, PB_8); |
kurton_ing | 0:89c243df8710 | 4 | Serial pc(USBTX, USBRX); |
kurton_ing | 0:89c243df8710 | 5 | InterruptIn TIPKALO2(PB_9); |
kurton_ing | 0:89c243df8710 | 6 | DigitalOut LEDICA1(PC_8); |
kurton_ing | 0:89c243df8710 | 7 | Ticker serial; |
kurton_ing | 0:89c243df8710 | 8 | |
kurton_ing | 0:89c243df8710 | 9 | int x=0; |
kurton_ing | 0:89c243df8710 | 10 | volatile int n=0; |
kurton_ing | 0:89c243df8710 | 11 | |
kurton_ing | 0:89c243df8710 | 12 | |
kurton_ing | 0:89c243df8710 | 13 | |
kurton_ing | 0:89c243df8710 | 14 | void brojac(){ |
kurton_ing | 0:89c243df8710 | 15 | n++; |
kurton_ing | 0:89c243df8710 | 16 | if(n>2){ |
kurton_ing | 0:89c243df8710 | 17 | n=0; |
kurton_ing | 0:89c243df8710 | 18 | } |
kurton_ing | 0:89c243df8710 | 19 | } |
kurton_ing | 0:89c243df8710 | 20 | |
kurton_ing | 0:89c243df8710 | 21 | |
kurton_ing | 0:89c243df8710 | 22 | |
kurton_ing | 0:89c243df8710 | 23 | void komunikacija(){ |
kurton_ing | 0:89c243df8710 | 24 | pc.printf("%d", x); |
kurton_ing | 0:89c243df8710 | 25 | } |
kurton_ing | 0:89c243df8710 | 26 | |
kurton_ing | 0:89c243df8710 | 27 | |
kurton_ing | 0:89c243df8710 | 28 | |
kurton_ing | 0:89c243df8710 | 29 | int main() |
kurton_ing | 0:89c243df8710 | 30 | { |
kurton_ing | 0:89c243df8710 | 31 | TIPKALO2.mode(PullDown); |
kurton_ing | 0:89c243df8710 | 32 | TIPKALO2.rise(&brojac); |
kurton_ing | 0:89c243df8710 | 33 | serial.attach(&komunikacija, 5); |
kurton_ing | 0:89c243df8710 | 34 | while(1){ |
kurton_ing | 0:89c243df8710 | 35 | switch(n){ |
kurton_ing | 0:89c243df8710 | 36 | case 1: |
kurton_ing | 0:89c243df8710 | 37 | x = LED.flash(x); |
kurton_ing | 0:89c243df8710 | 38 | break; |
kurton_ing | 0:89c243df8710 | 39 | case 2: |
kurton_ing | 0:89c243df8710 | 40 | LEDICA1=!LEDICA1; |
kurton_ing | 0:89c243df8710 | 41 | wait(2); |
kurton_ing | 0:89c243df8710 | 42 | LEDICA1=!LEDICA1; |
kurton_ing | 0:89c243df8710 | 43 | wait(1); |
kurton_ing | 0:89c243df8710 | 44 | break; |
kurton_ing | 0:89c243df8710 | 45 | } |
kurton_ing | 0:89c243df8710 | 46 | |
kurton_ing | 0:89c243df8710 | 47 | } |
kurton_ing | 0:89c243df8710 | 48 | |
kurton_ing | 0:89c243df8710 | 49 | } |