gggggg

Files at this revision

API Documentation at this revision

Comitter:
yusuke_robocup
Date:
Mon Mar 04 09:10:48 2013 +0000
Commit message:
ggggg

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 521d2ffbfecf main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 04 09:10:48 2013 +0000
@@ -0,0 +1,254 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+int main() {
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+    }
+}
+
+#include <Wire.h>
+#include <SoftwareSerial.h>
+
+SoftwareSerial hexmot(4,5); //rx:4 tx:5
+
+void setup()
+{
+  Serial.begin(9600);
+  hexmot.begin(19200);
+}
+
+void loop()
+{
+  serialhexmot(100,-100,0,50,-50,1);
+  delay(500);
+}
+
+void serialhexmot(int a,int b,int c,int d,int e,int f)
+{
+  int z = 0;
+  int input[6] = {a,b,c,d,e,f};
+  int output[6] = {0,0,0,0,0,0};
+  int val = 0;
+  String StringA = 0;
+  String StringB = 0;
+  String StringC = 0;
+  String StringD = 0;
+  String StringE = 0;
+  String StringF = 0;
+  String StringX = 0;
+  String StringY = 0;
+  String StringZ = 0;
+  String String0 = 0;
+  
+    StringX = String(1);
+    val = input[0];//*100/255;
+    if(val < 0 && val >= -100)
+    {
+      StringY = String('R');
+      val = abs(val);
+      StringZ = String(val);
+    }
+    else if(val >= 0 && val <= 100)
+    {
+      StringY = String('F');
+      StringZ = String(val);
+    }
+    else
+    {
+      StringY = String('F');
+      StringZ = String(0);
+    }
+    if(val < 10)
+    {
+      String0 = String("00");
+      StringZ = String0 + StringZ;
+    }
+    else if(val < 100)
+    {
+      String0 = String('0');
+      StringZ = String0 + StringZ;
+    }
+    else
+    {
+      String0 = String("");
+    }
+    StringA = StringX + StringY + StringZ;
+    
+    
+    StringX = String(2);
+    val = input[1];//*100/255;
+    if(val < 0 && val >= -100)
+    {
+      StringY = String('R');
+      val = abs(val);
+      StringZ = String(val);
+    }
+    else if(val >= 0 && val <= 100)
+    {
+      StringY = String('F');
+      StringZ = String(val);
+    }
+    else
+    {
+      StringY = String('F');
+      StringZ = String(0);
+    }
+    if(val < 10)
+    {
+      String0 = String("00");
+      StringZ = String0 + StringZ;
+    }
+    else if(val < 100)
+    {
+      String0 = String('0');
+      StringZ = String0 + StringZ;
+    }
+    else
+    {
+    }
+    StringB = StringX + StringY + StringZ;
+    
+    
+    StringX = String(3);
+    val = input[2];//*100/255;
+    if(val < 0 && val >= -100)
+    {
+      StringY = String('R');
+      val = abs(val);
+      StringZ = String(val);
+    }
+    else if(val >= 0 && val <= 100)
+    {
+      StringY = String('F');
+      StringZ = String(val);
+    }
+    else
+    {
+      StringY = String('F');
+      StringZ = String(0);
+    }
+    if(val < 10)
+    {
+      String0 = String("00");
+      StringZ = String0 + StringZ;
+    }
+    else if(val < 100)
+    {
+      String0 = String('0');
+      StringZ = String0 + StringZ;
+    }
+    else
+    {
+    }
+    StringC = StringX + StringY + StringZ;
+    
+    
+    StringX = String(4);
+    val = input[3];//*100/255;
+    if(val < 0 && val >= -100)
+    {
+      StringY = String('R');
+      val = abs(val);
+      StringZ = String(val);
+    }
+    else if(val >= 0 && val <= 100)
+    {
+      StringY = String('F');
+      StringZ = String(val);
+    }
+    else
+    {
+      StringY = String('F');
+      StringZ = String(0);
+    }
+    if(val < 10)
+    {
+      String0 = String("00");
+      StringZ = String0 + StringZ;
+    }
+    else if(val < 100)
+    {
+      String0 = String('0');
+      StringZ = String0 + StringZ;
+    }
+    else
+    {
+    }
+    StringD = StringX + StringY + StringZ;
+    
+    
+    StringX = String(5);
+    val = input[4];//*100/255;
+    if(val < 0 && val >= -100)
+    {
+      StringY = String('R');
+      val = abs(val);
+      StringZ = String(val);
+    }
+    else if(val >= 0 && val <= 100)
+    {
+      StringY = String('F');
+      StringZ = String(val);
+    }
+    else
+    {
+      StringY = String('F');
+      StringZ = String(0);
+    }
+    if(val < 10)
+    {
+      String0 = String("00");
+      StringZ = String0 + StringZ;
+    }
+    else if(val < 100)
+    {
+      String0 = String('0');
+      StringZ = String0 + StringZ;
+    }
+    else
+    {
+    }
+    StringE = StringX + StringY + StringZ;
+    
+    
+    StringX = String(6);
+    val = input[5];//*100/255;
+    if(val < 0 && val >= -100)
+    {
+      StringY = String('R');
+      val = abs(val);
+      StringZ = String(val);
+    }
+    else if(val >= 0 && val <= 100)
+    {
+      StringY = String('F');
+      StringZ = String(val);
+    }
+    else
+    {
+      StringY = String('F');
+      StringZ = String(0);
+    }
+    if(val < 10)
+    {
+      String0 = String("00");
+      StringZ = String0 + StringZ;
+    }
+    else if(val < 100)
+    {
+      String0 = String('0');
+      StringZ = String0 + StringZ;
+    }
+    else
+    {
+    }
+    StringF = StringX + StringY + StringZ;
+    
+    Serial.println(StringA+StringB+StringC+StringD+StringE+StringF);  
+    hexmot.println(StringA+StringB+StringC+StringD+StringE+StringF);
+}
diff -r 000000000000 -r 521d2ffbfecf mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Mar 04 09:10:48 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec
\ No newline at end of file