Nedim Hozić Kenan Mahmutović

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
tim007
Date:
Thu May 08 17:08:36 2014 +0000
Commit message:
PAI-Grupa7-Tim007-Zadatak1

Changed in this revision

TSI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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