Basic functions for Gravitech's i2c color sensor
Dependencies: mbed
Dependents: R5 2016 Robotics Team 1
Revision 1:b4139bd2715f, committed 2016-04-09
- Comitter:
- Hypna
- Date:
- Sat Apr 09 11:01:08 2016 +0000
- Parent:
- 0:42c0a779b199
- Commit message:
- did things
Changed in this revision
ColorSensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
ColorSensor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ColorSensor.cpp Sun Mar 20 23:28:40 2016 +0000 +++ b/ColorSensor.cpp Sat Apr 09 11:01:08 2016 +0000 @@ -1,13 +1,13 @@ #include "ColorSensor.h" //sda and scl are for your i2c pins -ColorSensor::ColorSensor(PinName sda, PinName scl) : i2c(sda, scl), gain(4), scale(1) +ColorSensor::ColorSensor(PinName sda, PinName scl) : i2c(sda, scl) { //power on device and ADCs i2c.write(ADDR, CTRL, 1); i2c.write(ADDR, CTRL_INIT, 1); - //intial gain is 4x, scale is 1x + //intial gain is 4x, scaler is 1x i2c.write(ADDR, GAIN, 1); i2c.write(ADDR, GAIN_INIT, 1); }
--- a/ColorSensor.h Sun Mar 20 23:28:40 2016 +0000 +++ b/ColorSensor.h Sat Apr 09 11:01:08 2016 +0000 @@ -4,7 +4,7 @@ #include "mbed.h" //constants for i2c register communication -const int ADDR = 0x72; +const int ADDR = 0x3A; const char CTRL_VAL = 0x80; const char* const CTRL = &CTRL_VAL; const char CTRL_INIT_VAL = 0x03;