I am using an Arduino Due (latest arduino IDE/drivers), with a Pixy (latest firmware, latest Pixymon). Im talking to pixy via I2C port.
I have a robot that drives around and follows a lane (color signature). The wheels are controlled with a PID type controller, and a command signal is determined based on a x coordinate of a detected color signature block. I dont read pixy data at constant time intervals, I read pixy every change I get. I noticed that my program is getting stuck every once in a while, it appears that the program is stuck in an infinite while() loop as soon as i begin reading pixy data.
Any ideas how I could fix it?
Here is what I thought was happening…
In my program, all variables are stored in preallocated memory. My program had Serial.begin() declared in setup, because once in a while i would print stuff out for debug purposes. My code does not have any Serial.print() stuff. However, pixy library does have Serial.println() stuff inside which prints out “cs” and “reorder” errors. I believe that every time an error happens, this dynamically allocates memory which eventually will cause arduino to crash?
At any rate, I commented out Serial.begin(), but the issue was still there.
Addition info: my PID controller/other code is solid. I narrowed it down to pixy.getBlocks() by printing stuff out to the console, as well as observing how my robot behaves (it has other sensors and such that affect how the wheels drive, and those sensors stop working)