Cameron Johnston / Mbed 2 deprecated Buggy_Control

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
CamJohnston
Date:
Thu Mar 23 11:38:29 2017 +0000
Commit message:
Elec1130 Buggy

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	Thu Mar 23 11:38:29 2017 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+AnalogIn Up(p16);
+AnalogIn Down(p17);
+AnalogIn Right(p18);
+AnalogIn Left(p19);
+
+DigitalOut RightUp(p24);
+DigitalOut RightDown(p23);
+DigitalOut LeftUp(p22);
+DigitalOut LeftDown(p21);
+
+
+int main()
+{
+    while(1) {
+    if (Up.read() > 0.83) {
+        RightUp.write(1);
+        RightDown.write(0);
+        LeftUp.write(1);
+        LeftDown.write(0);
+    }
+   if (Down.read() > 0.83) {
+        RightUp.write(0);
+        RightDown.write(1);
+        LeftUp.write(0);
+        LeftDown.write(1);
+    }
+   if (Right.read() > 0.83) {
+        RightUp.write(0);
+        RightDown.write(0);
+        LeftUp.write(1);
+        LeftDown.write(0);
+    }
+   if (Left.read() > 0.83) {
+        RightUp.write(1);
+        RightDown.write(0);
+        LeftUp.write(0);
+        LeftDown.write(0);
+        }
+    if (Left.read() < 0.83 & Right.read() < 0.83 & Down.read() < 0.83 & Up.read() < 0.83) {
+        RightUp.write(0);
+        RightDown.write(0);
+        LeftUp.write(0);
+        LeftDown.write(0);
+    }
+    }
+}    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 23 11:38:29 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ad3be0349dc5
\ No newline at end of file