tim007 tim007
/
LV8_PAI_Tim007_Z2
Jarebica Azra Djenasevic Emir
main.cpp@0:286e4dcde50c, 2014-05-12 (annotated)
- Committer:
- tim007
- Date:
- Mon May 12 07:07:11 2014 +0000
- Revision:
- 0:286e4dcde50c
LV8-Grupa1-PAI-Z2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim007 | 0:286e4dcde50c | 1 | #include "mbed.h" |
tim007 | 0:286e4dcde50c | 2 | |
tim007 | 0:286e4dcde50c | 3 | Serial pc(USBTX, USBRX); |
tim007 | 0:286e4dcde50c | 4 | DigitalIn kolone[4]={dp2, dp1, dp28, dp6}; |
tim007 | 0:286e4dcde50c | 5 | DigitalOut redovi[4]={dp9, dp10, dp11, dp13}; |
tim007 | 0:286e4dcde50c | 6 | Ticker ticker; |
tim007 | 0:286e4dcde50c | 7 | |
tim007 | 0:286e4dcde50c | 8 | char taster(){ |
tim007 | 0:286e4dcde50c | 9 | char a='F'; |
tim007 | 0:286e4dcde50c | 10 | for(int i=0; i<4; i++){ |
tim007 | 0:286e4dcde50c | 11 | redovi[i]=1; |
tim007 | 0:286e4dcde50c | 12 | if(i==0){ |
tim007 | 0:286e4dcde50c | 13 | if(kolone[0]==1) a='1'; |
tim007 | 0:286e4dcde50c | 14 | if(kolone[1]==1) a='4'; |
tim007 | 0:286e4dcde50c | 15 | if(kolone[2]==1) a='7'; |
tim007 | 0:286e4dcde50c | 16 | if(kolone[3]==1) a='*'; |
tim007 | 0:286e4dcde50c | 17 | } |
tim007 | 0:286e4dcde50c | 18 | else if(i==1){ |
tim007 | 0:286e4dcde50c | 19 | if(kolone[0]==1) a='2'; |
tim007 | 0:286e4dcde50c | 20 | if(kolone[1]==1) a='5'; |
tim007 | 0:286e4dcde50c | 21 | if(kolone[2]==1) a='8'; |
tim007 | 0:286e4dcde50c | 22 | if(kolone[3]==1) a='0'; |
tim007 | 0:286e4dcde50c | 23 | } |
tim007 | 0:286e4dcde50c | 24 | else if(i==2){ |
tim007 | 0:286e4dcde50c | 25 | if(kolone[0]==1) a='3'; |
tim007 | 0:286e4dcde50c | 26 | if(kolone[1]==1) a='6'; |
tim007 | 0:286e4dcde50c | 27 | if(kolone[2]==1) a='9'; |
tim007 | 0:286e4dcde50c | 28 | if(kolone[3]==1) a='#'; |
tim007 | 0:286e4dcde50c | 29 | } |
tim007 | 0:286e4dcde50c | 30 | else if(i==3){ |
tim007 | 0:286e4dcde50c | 31 | if(kolone[0]==1) a='A'; |
tim007 | 0:286e4dcde50c | 32 | if(kolone[1]==1) a='B'; |
tim007 | 0:286e4dcde50c | 33 | if(kolone[2]==1) a='C'; |
tim007 | 0:286e4dcde50c | 34 | if(kolone[3]==1) a='D'; |
tim007 | 0:286e4dcde50c | 35 | } |
tim007 | 0:286e4dcde50c | 36 | redovi[i]=0; |
tim007 | 0:286e4dcde50c | 37 | } |
tim007 | 0:286e4dcde50c | 38 | return a; |
tim007 | 0:286e4dcde50c | 39 | } |
tim007 | 0:286e4dcde50c | 40 | |
tim007 | 0:286e4dcde50c | 41 | void prikaz() |
tim007 | 0:286e4dcde50c | 42 | { |
tim007 | 0:286e4dcde50c | 43 | char c=taster(); |
tim007 | 0:286e4dcde50c | 44 | if(c==0) |
tim007 | 0:286e4dcde50c | 45 | return; |
tim007 | 0:286e4dcde50c | 46 | if(c!='*' && c!='F') |
tim007 | 0:286e4dcde50c | 47 | pc.putc(c); |
tim007 | 0:286e4dcde50c | 48 | else if(c=='*') |
tim007 | 0:286e4dcde50c | 49 | pc.putc('\n'); |
tim007 | 0:286e4dcde50c | 50 | } |
tim007 | 0:286e4dcde50c | 51 | int main() { |
tim007 | 0:286e4dcde50c | 52 | ticker.attach(prikaz,0.3); |
tim007 | 0:286e4dcde50c | 53 | |
tim007 | 0:286e4dcde50c | 54 | while(1) { |
tim007 | 0:286e4dcde50c | 55 | |
tim007 | 0:286e4dcde50c | 56 | } |
tim007 | 0:286e4dcde50c | 57 | } |