Mesud KLisura Arnela Duzan

Dependencies:   TSI mbed

Committer:
tim004
Date:
Thu May 08 18:13:56 2014 +0000
Revision:
0:52d82f627c7b
LV8Grupa7tim004

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim004 0:52d82f627c7b 1 #include "mbed.h"
tim004 0:52d82f627c7b 2 #include "TSISensor.h"
tim004 0:52d82f627c7b 3
tim004 0:52d82f627c7b 4 PwmOut red(LED_RED);
tim004 0:52d82f627c7b 5 PwmOut green(LED_GREEN);
tim004 0:52d82f627c7b 6 PwmOut blue(LED_BLUE);
tim004 0:52d82f627c7b 7
tim004 0:52d82f627c7b 8 Serial pc(USBTX, USBRX);
tim004 0:52d82f627c7b 9 TSISensor senzor;
tim004 0:52d82f627c7b 10
tim004 0:52d82f627c7b 11 Ticker tick;
tim004 0:52d82f627c7b 12
tim004 0:52d82f627c7b 13 void ispisi()
tim004 0:52d82f627c7b 14 {
tim004 0:52d82f627c7b 15 pc.printf("Senzor: %g %\n", senzor.readPercentage()*100);
tim004 0:52d82f627c7b 16
tim004 0:52d82f627c7b 17 }
tim004 0:52d82f627c7b 18
tim004 0:52d82f627c7b 19 void Ukljuci(char c, float i) {
tim004 0:52d82f627c7b 20
tim004 0:52d82f627c7b 21 if(c == 'R') red = i;
tim004 0:52d82f627c7b 22 else if(c == 'G') green = i;
tim004 0:52d82f627c7b 23 else if(c == 'B') blue = i;
tim004 0:52d82f627c7b 24 else return;
tim004 0:52d82f627c7b 25 }
tim004 0:52d82f627c7b 26
tim004 0:52d82f627c7b 27 int main()
tim004 0:52d82f627c7b 28 {
tim004 0:52d82f627c7b 29 red = 1;
tim004 0:52d82f627c7b 30 green = 1;
tim004 0:52d82f627c7b 31 blue = 1;
tim004 0:52d82f627c7b 32
tim004 0:52d82f627c7b 33 while(1)
tim004 0:52d82f627c7b 34 {
tim004 0:52d82f627c7b 35 char znak = pc.getc();
tim004 0:52d82f627c7b 36 if(znak == 'P') tick.attach(&ispisi, 1);
tim004 0:52d82f627c7b 37 else if(znak=='Z') tick.detach();
tim004 0:52d82f627c7b 38 else
tim004 0:52d82f627c7b 39 {
tim004 0:52d82f627c7b 40 int p=(pc.getc() - '0') * 10;
tim004 0:52d82f627c7b 41 int d=pc.getc() - '0';
tim004 0:52d82f627c7b 42 red = green = blue = 1;
tim004 0:52d82f627c7b 43 float intenzitet=(p+d)/100.;
tim004 0:52d82f627c7b 44 Ukljuci(znak,intenzitet);
tim004 0:52d82f627c7b 45 }
tim004 0:52d82f627c7b 46 }
tim004 0:52d82f627c7b 47 }