Hi
If the solution to my problem is glaringly obvious, I apologize in advance. I’m new to this stuff.
I have a Mega with a Waveshield, modified (butchered) as shown here: http://paulhartigan.net/2012/01/01/wave-shield-and-arduino-mega-2650/
In my main loop I play a few sounds and call a method which at present simply rotates a servo (on pin 6) from 0 to 180 and back again. To control the servo I have had to use the ServoTimer2 library because the Waveshield uses Timer1, which is also used by the standard Arduino Servo library.
Anyway, the Waveshield and ServoTimer2 play nicely together.
The problem arises when I add into the loop a call to the following method, which acquires data from an Omron D6T-8L thermal sensor connected to pins 20 (SDA) and 21 (SCL):
void readTemperatures(){
int i = 0 ;
Wire.beginTransmission(0x0A);
Wire.write(0x4C);
int writeStatus = Wire.endTransmission();
if(writeStatus != 0){
//Serial.println("Writing failed");
return;
}
delay(300);
Wire.requestFrom(0x0A, 18);
for (i = 0 ; i < 35 ; i++) {
rbuf [i] = Wire.read();
}
T_PTAT = (rbuf[0]+(rbuf[1] << 8));
for (i = 0 ; i < 8 ; i++) {
TDATA [i] = (rbuf [(i * 2 + 2)] + ( rbuf [(i * 2 + 3)] << 8 ));//offset by 2 because T_PTAT occupies the first 2 bytes
}
}
(rbuf, T_PTAT and TDATA are defined earlier)
That just stops the servo dead. To summarize: Waveshield + ServoTimer2 = OK. Waveshield + reading the temperature sensor = OK. All three together = servo stops when readTemperature is called.
Any ideas?