I have a Pololu 3pi with an accelerometer attached to pin 5. I can read from it and display the value on the LCD no problem.
However, after I call robot.init(2000) in order to use the line following feature, the accelerometer always returns 0.
Here is a simplified version of my code:
#include <OrangutanLCD.h>
#include <OrangutanMotors.h>
#include <OrangutanBuzzer.h>
#include <PololuQTRSensors.h>
#include <Pololu3pi.h>
int accelPin = 5;
Pololu3pi robot;
unsigned int sensors[5];
void setup() {
pinMode(accelPin, INPUT);
}
void loop() {
robot.init(2000);
while (true) {
clear();
lcd_goto_xy(0, 0);
print_long(analogRead(accelPin));
delay(10);
}
}
Without the line robot.init(2000), the accelerometer works perfectly; with it, it returns only 0. Any ideas?