pic - TCS34725 color sensor readings fluctuate when interfacing with PIC16 -


i trying read values of tcs34725 color sensor pic16 through i2c. currently, continuously polling clear register on tcs. however, every 10 or times read value in clear register, random drop in readings. example, set of consecutive readings may [17, 17, 17, 17, 17, 17, 17, 17, 14, 15, 16, 17 ...], repeating.

i have tried interfacing arduino uno in same situation , consistent reading of 17.

i eliminate drop in readings.

the code have in xc8 reading tcs follows

void read_colorsensor(void){ unsigned char color_low[4]; unsigned char color_high[4]; int i; i2c_master_start(); i2c_master_write(0b01010010);   //7bit address 0x29 + write i2c_master_write(0b10110100);   //write cmdreg + access&increment clear low reg i2c_master_stop();  i2c_master_start();     //repeated start command combined i2c i2c_master_write(0b01010011);   //7bit address 0x29 + read color_low[0] = i2c_master_read(1); color_high[0] = i2c_master_read(0); i2c_master_stop(); color[0] = (color_high[0] << 8)|(color_low[0]); return; } 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -