Quote:
Originally Posted by pblankenbaker
Are you using the color sensor found at: http://www.modernroboticsinc.com/color-sensor
If so, it looks like product page indicates that the address of the sensor is 0x3C. Could it be that you just need to change:
Code:
ColorSensor = new I2C(I2C.Port.kOnboard, 0x1E);
To:
Code:
ColorSensor = new I2C(I2C.Port.kOnboard, 0x3C);
|
I am not familiar with the I2C class in WPILib but it depends on whether the regAddress parameter in the I2C constructor is expecting a 7-bit address or 8-bit address. If it is 8-bit, then 0x3C is the correct address. But if it is expecting a 7-bit address, then it should be 0x1E. In the I2C spec, register address is actually 7 bits, the LSB of the 8-bit address is used to indicate whether it is a READ or WRITE transaction. So a 7-bit address must shift left one-bit to accommodate the READ/WRITE bit. The Modern Robotics Color Sensor spec specifies an 8-bit address. So it's already shifted one bit to the left. But if the WPILib I2C constructor is expecting a 7-bit address (i.e. it will internally shift one bit to the left and OR-in the READ/WRITE bit), then passing 0x1E to it is correct.
I recommend you try both and see which way it is.