Hi,
please can you tell me how to send data from a sensor (the IR receiver) from the first Arduino (the one with the IR connected) to another Arduino via serial communication?
I tried some different codes from the Internet, but they do not seem to work. The one without syntax errors turned out to be unworking... at least, someone on this forum said that.
I tried asking before about this, and as comprehension problems have arisen, here is a scheme to make all clear:
Remote controller > IR receiver > First arduino > Second arduino
I can't find a way to send data collected by the IR receiver from the first arduino to the second one.
Please help me...
I tried some different codes from the Internet, but they do not seem to work.
How do you know? How have you connected the Arduinos? What code are you trying to use?
Sending data via serial is done with Serial.print() or the same method in the SoftwareSerial, AltSoftSerial, or NeoSoftSerial software serial instance.
I did not connect the arduino board, the software reported some errors. I do not actually understand how to send the HEX values from the IR using the Serial.write() command... and how to store them in the second arduino using the Serial.read() command.
This is a code I tried for the sender...
#include <IRremote.h>
int receiver = 2;
IRrecv irrecv(receiver);
decode_results results;
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
Serial.write(results.value);
irrecv.resume(); // receive the next value
delay(80);
}
}
//code valid per sender