Amer Ratkovic Emir Mujacic

Dependencies:   mbed

main.cpp

Committer:
tim003
Date:
2014-05-08
Revision:
0:1934e76e6ba6

File content as of revision 0:1934e76e6ba6:

#include "mbed.h"

Serial PC (USBTX, USBRX);

DigitalIn kol1(dp9), kol2(dp10),kol3(dp11), kol4(dp13);
DigitalOut red1(dp2), red2(dp1), red3(dp28),red4(dp6);

Timer t;
char slovo;
char ocitaj()
{
    red1=0;red2=0;red3=0;red4=0;
    red1=1;
    if(kol1==1) return '1';
    if(kol2==1) return '2';
    if(kol3==1) return '3';
    if(kol4==1) return 'A';

    red1=0;
    red2=1;
    if(kol1==1) return '4';
    if(kol2==1) return '5';
    if(kol3==1) return '6';
    if(kol4==1) return 'B';
    red2=0;
    red3=1;
    if(kol1==1) return '7';
    if(kol2==1) return '8';
    if(kol3==1) return '9';
    if(kol4==1) return 'C';
    red3=0;
    red4=1;
    if(kol1==1) return '\n';
    if(kol2==1) return '0';
    if(kol3==1) return '#';
    if(kol4==1) return 'D';
    red4=0;
    return 'X';
}


void funkcija()
{
    if(t.read_ms() < 222)
        return;
    slovo = ocitaj();
    if(slovo == 'X')
        return;
    PC.printf("%c",slovo);

    t.reset();
}

int main()
{
    t.start();
    while(1)
    {
        funkcija();
    }
}