a beter verjin

Dependencies:   m3pi mbed ADJD-S371_ColourSens

Fork of TestColorSensor by Kyle Chiang

Files at this revision

API Documentation at this revision

Comitter:
TaintedTruth
Date:
Thu Nov 21 00:21:52 2013 +0000
Parent:
2:5c0159599726
Child:
4:f38d0db83e1c
Commit message:
testing stuff;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Nov 21 00:13:13 2013 +0000
+++ b/main.cpp	Thu Nov 21 00:21:52 2013 +0000
@@ -2,22 +2,21 @@
 #include "m3pi.h"
 
 DigitalOut sensorLED(p8);
-I2C colorSensor(p28, p27);
+I2C colorSensor(p28, p27); //SDA, SCL
 Serial bt(p13, p14); // tx, rx
 
 const int addr = 0x74;
+const int addr1 = 0x75;
 m3pi m3pi;
 
 int read(char lowByteRegister) {
         char cmd[1];
-        char echo[1];
-        bt.printf("E:%0x ",echo[0]);
+        char echo[2];
 
         cmd[0] = lowByteRegister;
         colorSensor.write(addr,cmd,1);
-        colorSensor.read(addr,echo,1);
+        colorSensor.read(addr,echo,2);
         int result_low = (int) echo[0];
-        bt.printf("lo:%0x ",result_low);
         
         /*
         cmd[0] = lowByteRegister + 1;
@@ -47,6 +46,10 @@
         cmd[1] = 0x01;
         colorSensor.write(addr,cmd,2);
         
+        cmd[0] = 0x06;
+        cmd[1] = 0x04;
+        colorSensor.write(addr,cmd,2);
+        
         int red = read(0x06);
         // int green = read(0x42);
         // int blue = read(0x44);