I am having a really hard time getting my blue-tooth shield to work, so I started to write a program that sent messages via the USB/serial connection from my Uno to my PC. Here's the code:
int inByte = 0; // incoming serial byte
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
establishContact(); // send a byte to establish contact until receiver responds
}
void loop()
{
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
Serial.write(inByte);
Serial.print('B'); // send a capital A
}
}
void establishContact() {
while (Serial.available() <= 0) {
Serial.print('A'); // send a capital A
delay(300);
}
}
The thing is, this works fine if it is JUST the arduino--but if I plug in the BT shield (and change NOTHING in the code, just reupload) the thing breaks!!! Instead of responding to commands, it just keeps sending 'A' ad infinitum.
This doesn't make any sense to me but I am hoping you guys know what is going on. Why would plugging in a shield have any impact at all on a program that doesn't use the shield in the first place???