d

Dependencies:   Motor Servo mbed

Files at this revision

API Documentation at this revision

Comitter:
iemretep
Date:
Fri Apr 21 04:03:52 2017 +0000
Commit message:
Robot;

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
Servo.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
diff -r 000000000000 -r 1f5a1332637b Motor.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Fri Apr 21 04:03:52 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Motor/#f265e441bcd9
diff -r 000000000000 -r 1f5a1332637b Servo.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.lib	Fri Apr 21 04:03:52 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 1f5a1332637b main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 21 04:03:52 2017 +0000
@@ -0,0 +1,50 @@
+#include "mbed.h"
+#include "Motor.h"
+#include "Servo.h"
+//Reads in joystick positions from controller and drives the motors. 
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+AnalogIn jx1(p16);
+AnalogIn jy1(p15);
+//AnalogIn jx2
+//AnalogIn jy2
+float mot_x = 0.5;
+float mot_y = 0.5;
+float cam_x = 0;
+float cam_y = 0;
+
+char buf[32];
+int idx = 0;
+
+Serial pc(p9,p10);
+//Serial pc(USBTX, USBRX);
+
+Motor A(p21, p20, p19);  //pwm, inB, inA
+Motor B(p22, p17, p12); //pwm, inA, inB
+
+
+int main()
+{
+    pc.baud(115200);
+    while(1) {
+            int x = pc.getc();
+            
+            if(x == -1) continue;
+            
+            //while(!pc.readable());
+            buf[idx] = (char)x; 
+            
+            if(buf[idx] == '\r' || buf[idx] == '\n'){
+                sscanf(buf, "%f %f %f %f", &mot_x, &mot_y, &cam_x, &cam_y);
+                A.speed(mot_x);
+                B.speed(mot_y); 
+                idx = 0;
+            }else{
+                idx++;
+            }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 1f5a1332637b mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 21 04:03:52 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/856d2700e60b
\ No newline at end of file