Hello,
I am trying to send three analog values over a serial connection from one arduino uno to an arduino duemilanove. I have 3 10k pots connected to three analog inputs of the UNO using ground and 3.3V. Then on the DUEMILANOVE I have the PMW outupts conneccted to three leds. Eventually I will send these values using an XBEE but for right now I have the RX pin of the UNO to the TX Pin of the DUEMILANOVE and the TX pin of the UNO to the RX Pin of the DUEMILANOVE... My codes works but a minute in one of my LEDS will continue to blink even when it should be off.
The code for the uno is
int analogValue5, val5;
int analogValue2, val2;
int analogValue0, val0;
void setup()
{
Serial.begin(115200);
}
void loop()
{
analogValue5 = analogRead(5);
analogValue2 = analogRead(2);
analogValue0 = analogRead(0);
val5 = map(analogValue5, 0, 1023, 0, 255);
val2 = map(analogValue2, 0 ,1023, 0, 255);
val0 = map(analogValue0, 0, 1023, 0, 255);
Serial.write('A');
Serial.write(val0);
delay(10);
Serial.write('d');
Serial.write(val2);
delay(10);
Serial.write('C');
Serial.write(val5);
delay(10);
}
The code for DUEMILANOVE
byte incomingByte;
byte sensor1, sensor2;
byte sensor3;
void setup()
{
Serial.begin(115200);
pinMode ( 9, OUTPUT);
pinMode (10, OUTPUT);
pinMode ( 6, OUTPUT);
}
void loop() {
if (Serial.available())
{
incomingByte = Serial.read();
Serial.print(int(incomingByte));
if ((int(incomingByte) == 'C'))
{
sensor1 = Serial.read();
Serial.print(int(sensor1));
delay(10);
}
if ((int(incomingByte) == 'd'))
{
sensor2 = Serial.read();
Serial.print(int(sensor2));
delay(10);
}
if ((int(incomingByte) == 'A'))
{
sensor3 = Serial.read();
Serial.print(int(sensor3));
delay(10);
}
}
analogWrite( 9, sensor1);
analogWrite( 10, sensor2);
analogWrite( 6, sensor3);
// delay(10);
}
Thnks for the help in advance.