Car blink left & right

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
robert_gutknecht
Date:
Sat Apr 20 13:45:13 2013 +0000
Commit message:
blinker

Changed in this revision

blink.cpp Show annotated file Show diff for this revision Revisions of this file
blink.h 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/blink.cpp	Sat Apr 20 13:45:13 2013 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+#include "blink.h"
+
+DigitalOut myled1(LED1);
+DigitalOut myled2(LED4);
+
+void blink_l(){
+    myled1=1;
+    wait(0.3);
+    myled1=0;
+    wait(0.3);
+}
+
+void blink_r(){
+    myled2=1;
+    wait(0.3);
+    myled2=0;
+    wait(0.3);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/blink.h	Sat Apr 20 13:45:13 2013 +0000
@@ -0,0 +1,8 @@
+#ifndef BLINK_H_
+#define BLINK_H_
+
+void blink_l();
+void blink_r();
+
+
+#endif /*BLINK_H_*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 20 13:45:13 2013 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+#include "blink.h"
+
+InterruptIn time_l(p16);
+InterruptIn time_r(p18);
+DigitalIn taster_l(p16);
+DigitalIn taster_r(p18);
+
+Timer t1;
+Timer t2;
+
+void start_t1(){
+t1.start();
+}
+
+void stop_t1(){
+t1.stop();
+}
+
+
+void start_t2(){
+t2.start();
+}
+
+void stop_t2(){
+t2.stop();
+}
+
+int main() {
+    time_l.rise(&start_t1);
+    time_l.fall(&stop_t1);
+    time_r.rise(&start_t2);
+    time_r.fall(&stop_t2);
+    
+    while(1) {
+        if(taster_l){
+           wait(0.11);
+            
+            if(((t1.read_ms()<=100)&&(t1.read_ms()>0))==1){
+                blink_l();
+                blink_l();
+                blink_l();
+                blink_l();
+                t1.reset();
+             }
+             else {/*if(taster_l){*/ //blinkt solange taster gedrückt
+                blink_l();
+                t1.reset();
+             } 
+        }
+        if(taster_r){
+           wait(0.11);
+            
+            if(((t2.read_ms()<=100)&&(t2.read_ms()>0))==1){
+                blink_r();
+                blink_r();
+                blink_r();
+                blink_r();
+                t2.reset();
+             }
+             else {/*if(taster_l){*/ //blinkt solange taster gedrückt
+                blink_r();
+                t2.reset();
+             } 
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Apr 20 13:45:13 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file