I've got two Arduino Unos with two wireless protos and two xbee S1s and I would like to have a pot sent from one arduino to the other wirelessly. On the sender arduino it outputs to the serial monitor nicely, but the receiver serial monitor is spiting out random numbers and I can't quite figure out why. Am I not formatting the data correctly? Syntax problem? or baud rate problem?
Here is my code:
Sender Arduino
#include <SoftwareSerial.h>
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogInPin2 = A1; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
int sensorValue2 = 0; // value read from the pot
int outputValue = 0;
int outputValue2 = 0;
void setup() {
Serial.begin(9600);
delay(500);
}
void loop() {
sensorValue = analogRead(analogInPin); // read the analog in value:
sensorValue2 = analogRead(analogInPin2); // read the analog in value:
outputValue = map(sensorValue, 0, 1023, 0, 255); // map it to the range of the analog out:
outputValue2 = map(sensorValue2, 0, 1023, 0, 255); // map it to the range of the analog out:
Serial.println(outputValue);
delay(50);
}
Receiver Arduino
int GotInt = 0;
void setup ()
{
Serial.begin(9600);
delay(500);
}
void loop()
{
while(Serial.available() > 0)
{
GotInt = Serial.read();
Serial. println(GotInt);
}
}
The sender serial monitor is currently showing: repeating 16
The receiver serial monitor is currently showing:
10
49
54
13
(repeat)
This seems like this should be an easy fix.