<< return to Pixycam.com

communicate via avr i2c

hi,
recently i received my pixy and i want to hook it with my robot using atmega64 i2c communication.
but i have problem figuring out what to do.

this is my Getword function:(my pixy address is 0xD0)

int GetWord(){

unsigned char byte1=0;
unsigned char byte2; 
int word;
i2c_start();
i2c_write(0xD1);
byte1=i2c_read(0);
byte2=i2c_read(0);
i2c_stop();
word= byte2*256 + byte1;
return word;

}

but it only returns 255

tanks for your help;

Hello Mohammad,
I don’t know anything about your platform, but that looks like an odd set of calls to send/receive i2c data. What does the i2c_read argument do?

Other things to check – you need to change the data out port to i2c and set the i2c address. Note that the i2c address on the configuration screen is for read and write, so the value is actually divided by 2 (0xD0/2 = 0x68). It looks like you are using a different i2c address convention where 0xD1 for write and 0xD0 for read. Try 0x68 for Pixy’s address.

Also be sure you are in “default” mode (not cooked) when testing communications. This video does a good job of explaining:

Hope this helps!

Edward