I have an interesting problem. I have a library to control my Rover that mostly controls a motor driver but also has Grove buzzer, touch sensor and ultrasonic sensors.
I am using the older QTR1A sensors (3 of them). I have them working fine with a simple line follow
sketch. However when I include my library (nothing else, no code, just the include), the sensors start getting 0 for all their readings. I have no idea why and I am out of ideas.
I’m uploading the sketch and the library. I hope somebody can point me in the right direction
You specified the analog version of the QTR sensors (the QTR-1A Reflective Sensor), but your code looks like it is set up for the QTR-1RC version (i.e. you call qtr.setTypeRC(); in your initSensors() function). Could you clarify which version you’re actually using? Also, what microcontroller board are you using?
I don’t immediately see what would be causing that kind of problem, but you could try progressively commenting/uncommenting parts of the library to try to narrow it down.
Hi Brandon,
Many thanks for your reply. Yes I’m using these guys:
I guess I’m calling the wrong init function. Not sure if that would cause anything but I will try and use that method of eliminating the code bit by bit.
I’m using a PID algorithm for our robot which is working (quite) well with 3 of the sensors but I’m thinking that it could work even better with your later sensor arrays. I’ll get round to trying them soon.
I would not expect the initialize function for the QTR-RC sensors to work with the QTR-A sensors, so I recommend fixing that first and seeing if your problem persists.
Thanks again for your reply!
I changed the type to setTypeAnalog() which as I expected worked but no appreciable difference to the ‘RC’ method. I’ll keep it to analog from now on.
I worked out the issue by commenting out everything. The issue was pitches.h which redefines A1, A2 and A3 which are the sensors I am using. Hilarious!