tim003 tim003
/
LAB8_Grupa5_Tim003_Zadatak1
Amer Ratkovic Emir Mujacic
Diff: main.cpp
- Revision:
- 0:a81f84926340
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 08 13:16:01 2014 +0000 @@ -0,0 +1,99 @@ +#include "mbed.h" +#include "TSISensor.h" + + +Serial pc(USBTX, USBRX); +PwmOut red(LED_RED), green(LED_GREEN),blue(LED_BLUE); +TSISensor tsi; + +Ticker t; + +void ispis() +{ + pc.printf("\nTSI: %f",tsi.readPercentage()); +} + +float brightness = 0.0; +int main() { + int brojac=0; + red=1.; green=1.; blue=1.; + pc.printf("Unesi XDD ili P ili Z:"); + float svjetlo; + while(1) { + char a; + a=pc.getc(); + + if(a=='R') + { + char b=pc.getc(); + if(b>='0' && b<='9') + { + svjetlo=(b-48)*10; + char c=pc.getc(); + if(c>='0' && c<='9') + { + red=1; blue=1; green=1; + svjetlo+=c-48; + svjetlo=svjetlo/100.; + svjetlo=1-svjetlo; + red=svjetlo; + } + + } + } + + if(a=='G') + { + char b=pc.getc(); + if(b>='0' && b<='9') + { + svjetlo=(b-48)*10; + char c=pc.getc(); + if(c>='0' && c<='9') + { + red=1; blue=1; green=1; + svjetlo+=c-48; + svjetlo=svjetlo/100.; + svjetlo=1-svjetlo; + green=svjetlo; + } + + } + } + + if(a=='B') + { + + char b=pc.getc(); + if(b>='0' && b<='9') + { + svjetlo=(b-48)*10; + char c=pc.getc(); + if(c>='0' && c<='9') + { + red=1; blue=1; green=1; + svjetlo+=c-48; + svjetlo=svjetlo/100.; + svjetlo=1-svjetlo; + blue=svjetlo; + } + + } + } + + + if(a=='P') + { + red=1; blue=1; green=1; + t.attach(&ispis,1); + } + + if(a=='Z') + { + red=1; blue=1; green=1; + t.detach(); + } + + + } +}