I'm working on a program that talks between two arduinos, most of you have helped me a whole heck of a lot already with my project so you might be familiar with my code. Well I believe that my code is 100% correctly written but it only works right after I upload it to the Arduino. Let me explain more:
If I plug it in via usb and upload the program it works perfectly, I can see it on the serial monitor working 100% and the TX led is flashing.
Once I unplug it from the USB cord and use either a 9V battery adapter or plug the USB cord back in, it will not work, the ON led is lit up but the TX does not flash, the only thing I can get it to do is flash the L button after I reset it.
Has this ever happened before? I have tried with another arduino and i get the same results so the problem is in my code.
My code:
// SENDER
int grabValue, wristValue, elbowValue, shoulderValue, twistValue, val1, val2, val3, val4, val5;
void setup()
{
// start serial port at 19200 bps
Serial.begin(19200);
}
void loop()
{
// reads analog input for each sensor on the controling arm
grabValue = analogRead(0);
wristValue = analogRead(1);
elbowValue = analogRead(2);
shoulderValue = analogRead(3);
twistValue = analogRead(4);
// remap values
// 251 through 255 for SYNC
val1 = map(grabValue, 0, 1023, 0, 249);
val2 = map(wristValue, 0, 1023, 0, 249);
val3 = map(elbowValue, 0, 1023, 0, 249);
val4 = map(shoulderValue, 0, 1023, 0, 249);
val5 = map(twistValue, 0, 1023, 0, 249);
Serial.print(251, BYTE); //SYNC char
Serial.print(val1, BYTE);
Serial.print(252, BYTE); //SYNC char
Serial.print(val2, BYTE);
Serial.print(253, BYTE); //SYNC char
Serial.print(val3, BYTE);
Serial.print(254, BYTE); //SYNC char
Serial.print(val4, BYTE);
Serial.print(255, BYTE); //SYNC char
Serial.print(val5, BYTE);
delay(150);
}