I’m testing this sensor with the program C on the BrickPi, and it returns me all times black, and random colours (or 7(null)). I try in all sensors ports and have the same results. My sensor is Hitechnic NXT Color Sensor v2.0. Do it works with the BrickPi? or am I doing something wrong?
The only color sensor supported nativly is the Lego NXT color sensor. You can use the HiTechnic color sensor with the I2C drivers. Go to http://sourceforge.net/apps/phpbb/mindboards/viewtopic.php?f=13&t=1994 and then expand and read the section “Using I2C devices on sensor ports 1-4”. It tells how to setup a sensor port to use I2C, and explains all the options available.
I’ve attached an example program. I don’t have the HT Color sensor V2, but I tested it with the HT Color sensor V1.
Thank you for reply. I tried your example program, but get an error. I read your page of BrickPî, but I dont get if I have problems with my BrickPi.h, need I2C drivers or something. Temporally I haven’t internet on my brickpi.
pi@raspberrypi ~/Desktop/comenius/Practicas $ gcc -o program "Test-BrickPi-HT-Color-sensor.c" -lrt -lm -L/usr/local/lib -lwiringPi In file included from Test-BrickPi-HT-Color-sensor.c:16:0: BrickPi.h: In function 'show_val': BrickPi.h:231:2: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default] BrickPi.h: In function 'BrickPiUpdateValues': BrickPi.h:479:7: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default] Test-BrickPi-HT-Color-sensor.c: In function 'main': Test-BrickPi-HT-Color-sensor.c:41:3: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
The program works fine by the way. Thank you.
pd: the code of the last post its only warnings.
Sorry, that example program does not have all the #includes for the libraries used.
If you update to the latest BrickPi.h file (just pushed a couple minutes ago) from https://github.com/mattallen37/BrickPiDev, it #includes all the libraries used (and now has drivers for hardware I2C on sensor port 5).