Hi there,
I'm trying to communicate between two arduinos using the Rx and Tx ports through the APC220 module.
Some points:
- Both modules has been properly programmed through RF-MAGIC software for Windows
- I'm NOT using USB to power the arduinos, since you cannot use serial communication for two things at the same time (inferference). I removed the APC220 module while uploading the code to Arduinos in order to prevent errors.
- The wiring is correct.
I'm trying to send a analog value from a potentiometer from the transmitter to the receiver.
In receiver code, I'm trying to compare this value, and if it's >250, it turns on a LED.
However, the LED isn't turning on.
Simple code
I believe it's a code error, since I never used Tx Rx ports before. Can you spot any code error?
TRANSMITTER CODE:
int value;
int Pin = A1;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(Pin);
Serial.write(value);
delay(2000);
}
RECEIVER CODE:
int value;
int ledPin = 8;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
value = Serial.read();
if (value>250){
digitalWrite(ledPin,HIGH);
}
else {digitalWrite(ledPin,LOW);}
}
Thank you so much for all the your attention, time and willing to help,
Matheus Bitencourt