US, Vjezba 4 Stol 4, Amer Surkovic, Mirza Herdic Zadatak 2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
2016US_AmerSurkovic
Date:
Fri Mar 25 14:27:07 2016 +0000
Commit message:
US, Vjezba 4 Stol 4, Amer Surkovic, Mirza Herdic Zadatak 2

Changed in this revision

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/main.cpp	Fri Mar 25 14:27:07 2016 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#define dp23 P0_0
+
+
+BusOut diode(dp23, dp24, dp25, dp26, dp27, dp5, dp6, dp28);
+AnalogIn fotoSenzor(dp9);
+DigitalOut enable(dp14);
+
+int ocitajFotoSenzor(){
+    if(fotoSenzor < 0.70f)
+      return 0;
+    else if(fotoSenzor >= 0.70f && fotoSenzor < 0.7375f)
+      return 1;
+    else if(fotoSenzor >= 0.7375f && fotoSenzor < 0.775f)
+      return 3;
+    else if(fotoSenzor >= 0.775f && fotoSenzor < 0.8125)
+      return 7;
+    else if(fotoSenzor >= 0.8125f && fotoSenzor < 0.85f)
+      return 15;
+    else if(fotoSenzor >= 0.85f && fotoSenzor < 0.8875f)
+      return 31;
+    else if(fotoSenzor >= 0.8875f && fotoSenzor < 0.925f)
+      return 63;
+    else if(fotoSenzor >= 0.925f && fotoSenzor < 0.9625f)
+      return 127;
+    else if(fotoSenzor >= 0.9625f)
+      return 255;
+
+
+}
+
+
+int main(){
+  enable = 0;
+
+  while(1){             // 2^n - 1
+    diode = ocitajFotoSenzor();
+    wait(0.05);
+  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Mar 25 14:27:07 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file