Vježba 3, spajanje optičkih senzora i provjera preko mbeda.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
JosipLupinski
Date:
Wed Nov 02 18:08:34 2016 +0000
Commit message:
Vjezba 3

Changed in this revision

Optick_senzor_short_code.cpp Show annotated file Show diff for this revision Revisions of this file
Opticki_senzor_long_code.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/Optick_senzor_short_code.cpp	Wed Nov 02 18:08:34 2016 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+DigitalOut myled1 (LED1);
+DigitalOut myled2 (LED2);
+DigitalIn reflective (p5);
+DigitalIn transmissive (p15);
+
+int main() {
+    
+        while(true){
+            
+            //lamapice se pale kada se prekine dovod svjetla na senzore
+            myled1 = !reflective;
+            myled2 = transmissive;
+
+        }
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Opticki_senzor_long_code.cpp	Wed Nov 02 18:08:34 2016 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+DigitalOut myled1 (LED1);
+DigitalOut myled2 (LED2);
+DigitalIn switchInput1 (p5);
+DigitalIn switchInput2 (p15);
+
+int main() {
+    
+    int switchState1, switchState2;
+    
+        while(true){
+        
+            //lamapice se pale kada se prekine dovod svjetla na senzore
+            switchState1 = switchInput1.read();
+            switchState2 = switchInput2.read();
+            
+            if(switchState1 == 1) myled1 = 0;
+            else myled1 = 1;
+            
+            if(switchState2 == 1) myled2 = 1;
+            else myled2 = 0;
+
+        }
+    
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Nov 02 18:08:34 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0
\ No newline at end of file