a

Fork of I2C_Master by LAXAN01

Revision:
4:186241a75818
Parent:
3:996d0d74fb11
Child:
5:221ce6ba655c
--- a/main.cpp	Wed Oct 24 06:09:41 2018 +0000
+++ b/main.cpp	Wed Oct 24 06:16:00 2018 +0000
@@ -6,7 +6,8 @@
 
 Serial serialPort( PTE0, PTE1);
 
-char motobuffer[3];
+char Rmotobuffer[3];
+char Lmotobuffer[3];
 
 int Right_ADDR = 0x14<<1;
 int Left_ADDR  = 0x15<<1;
@@ -21,8 +22,8 @@
     i2c.start();
     i2c.write(Right_ADDR);
     i2c.write(0);
-    i2c.write(0xe2);
-    i2c.write(0);
+    i2c.write(Lmotobuffer[1]);
+    i2c.write(Lmotobuffer[2]);
     i2c.stop();
 }
 void Driving_Left(void)
@@ -30,8 +31,8 @@
     i2c.start();
     i2c.write(Left_ADDR);
     i2c.write(0);
-    i2c.write(motobuffer[1]);
-    i2c.write(motobuffer[2]);
+    i2c.write(Rmotobuffer[1]);
+    i2c.write(Rmotobuffer[2]);
     i2c.stop();
 }
 
@@ -46,9 +47,12 @@
     wait_ms(100);
 
     int motorOutPut=2000;
-    motobuffer[0]=0x00;
-    motobuffer[1]= motorOutPut>>8;
-    motobuffer[2]=motorOutPut;
+    Rmotobuffer[0]=0x00;
+    Rmotobuffer[1]= motorOutPut>>8;
+    Rmotobuffer[2]=motorOutPut;
+    Lmotobuffer[0]=0x00;
+    Lmotobuffer[1]= motorOutPut>>8;
+    Lmotobuffer[2]=motorOutPut;
 
     Driving_Right();
     wait_ms(100);