ライントレーサテスト ロボット製作セミナー演習

Dependencies:   TB6612FNG2 mbed

Files at this revision

API Documentation at this revision

Comitter:
jksoft
Date:
Sat Aug 10 03:51:18 2013 +0000
Commit message:
Rev1

Changed in this revision

TB6612FNG2.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/TB6612FNG2.lib	Sat Aug 10 03:51:18 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/jksoft/code/TB6612FNG2/#051a7ecff13e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 10 03:51:18 2013 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+#include "TB6612.h"
+
+BusOut leds( LED1 , LED2 );
+AnalogIn floor_sensor[] = { (p15) , (p16) , (p17) , (p18) };
+TB6612 left(p21,p12,p11);
+TB6612 right(p22,p14,p13);
+DigitalIn sw(p29);
+
+int Sensor()
+{
+    int ret = 0;
+    if(floor_sensor[1].read_u16() > 10000)
+    {
+        ret |= 0x01;
+    }
+    if(floor_sensor[2].read_u16() > 10000)
+    {
+        ret |= 0x02;
+    }
+    
+    return(ret);
+}
+
+int main() {
+
+    sw.mode(PullUp);
+    
+    while(sw==1)
+    {
+        leds = Sensor();
+    }
+    
+    while(1) {
+        int val = Sensor();
+        
+        leds = val;
+        
+        switch(val)
+        {
+        case 0x01:
+            left = 100;
+            right = 0;
+            break;
+        case 0x02:
+            right = 100;
+            left = 0;
+            break;
+        case 0x03:
+            left = 100;
+            right = 100;
+            break;
+        default:
+            left = 0;
+            right = 0;
+            break;        
+        }
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 10 03:51:18 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e3affc9e7238
\ No newline at end of file