tim007 tim007
/
PAI-LV8-Grupa7-Tim007-Zadatak1
Nedim Hozić Kenan Mahmutović
Revision 0:d62ace65b2b0, committed 2014-05-08
- Comitter:
- tim007
- Date:
- Thu May 08 17:08:36 2014 +0000
- Commit message:
- PAI-Grupa7-Tim007-Zadatak1
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Thu May 08 17:08:36 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 08 17:08:36 2014 +0000 @@ -0,0 +1,45 @@ +#include "mbed.h" +#include <ctype.h> +#include "TSISensor.h" + +PwmOut led[3] = {LED1, LED2, LED3}; + +Serial pc(USBTX, USBRX); // tx, rx +Ticker t; + +TSISensor tsi; + +void upaliDiodu(char c) +{ + char prva = pc.getc(), druga = pc.getc(); + int jacina = (prva - '0')*10 + druga - '0'; + led[0] = 1.0; + led[1] = 1.0; + led[2] = 1.0; + if(c=='R') + led[0]=1.0-jacina/100.0; + else if(c=='G') + led[1]=1.0-jacina/100.0; + else if(c=='B') + led[2]=1.0-jacina/100.0; +} + +void ispisiSenzor() +{ + printf("TSI: %.2f\n", tsi.readPercentage()); +} + +void ocitaj() +{ + char c = pc.getc(); + if(c=='R' || c=='G' || c=='B') + upaliDiodu(c); + if(c=='P') t.attach(ispisiSenzor, 1.0); + if(c=='Z') t.detach(); +} + +int main() { + led[0]=1.0; led[1]=1.0; led[2]=1.0; + pc.attach(ocitaj); + while(1); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 08 17:08:36 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file