Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ladner
Date:
Sun Nov 27 15:51:32 2016 +0000
Commit message:

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
diff -r 000000000000 -r 04038e713693 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 27 15:51:32 2016 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+
+BusOut myled(LED1,LED2,LED3,LED4);
+I2C i2c(p28, p27);
+DigitalOut von(p30);
+
+PwmOut L_EN(P1_15);//1 (p34)     
+DigitalOut L_FW(P1_0);   
+DigitalOut L_RV(P1_1);
+PwmOut R_EN(P0_21);//2 (p36)
+DigitalOut R_FW(P1_3);
+DigitalOut R_RV(P1_4);
+
+BusOut rgb(p25,p26,p14);
+
+DigitalOut online(P1_6);
+/*
+AnalogIn line1(p18);
+AnalogIn line2(p16);
+AnalogIn line3(p20);
+AnalogIn line4(p19);
+AnalogIn line5(p17);
+*/
+BusIn myline(p18,p16,p19,p17);
+DigitalIn linecenter(p20);
+
+
+//Nicht alles kann pwm!
+//https://developer.mbed.org/handbook/PwmOut
+
+int main() 
+{
+    rgb=7;
+    wait(0.2);
+    for(char i=0;i<4;i++)
+    {
+    myled=1<<i;
+    wait(0.2);
+    }
+    myled = 0;
+    von=1;
+    online = 1;
+    rgb=0;
+    R_FW=L_FW=1;
+    //R_EN=L_EN=1;
+    while(1)
+    {
+        /*
+        char data;
+        i2c.start(); 
+        i2c.write(0x40);
+        i2c.write(0x01);
+        i2c.start();
+        i2c.write(0x41);
+        data = i2c.read(0);
+        i2c.stop();
+        
+        
+        i2c.start();
+        i2c.write(0x40);
+        i2c.write(0x02);
+        i2c.write(0xF);
+        i2c.stop();
+        */
+        if(linecenter||myline)
+        {
+            if(myline&0x3)
+                L_EN=0;
+            else
+                L_EN=1;
+            if(myline&0xc)
+                R_EN=0;
+            else
+                R_EN=1;
+        }
+        else
+        {
+         R_FW=L_FW=0;
+         R_RV=L_RV=1;
+         wait(0.1);
+         R_EN=L_EN=0;
+         R_FW=L_FW=1;
+         R_RV=L_RV=0;
+         while(!(linecenter||myline));
+         }
+         
+    }
+}
diff -r 000000000000 -r 04038e713693 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Nov 27 15:51:32 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file