Hello:
I am hooking up 2 Arduino Nanons. Den one as "Master Reader" and the other as "Slave Sender". The wiring is correctly done with A4,A5 and GND.
On the "Slave sender" I have put the text Wire.write("5");
On the "Master Reader" in Serial print, it says "5" and it keeps repeating the number/text.
All OK.
But I want the "Master Reader" to execute a command, like turn on an LED, when the text is equivalent "5" and doing nothing when its not "5".
I have tried to use "if (c == "5"){ and the commands for LED here}, and nothing happens?
What I am doing wrong?
The idea is to send different commands/text from "Slave sender" to "Master reader" and then the "Master reader" will execute commands depending of the text.
Here is the code for "Master reader":
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
Wire.requestFrom(2, 1);
while(Wire.available()) {
char c = Wire.read();
Serial.print(c);
}
delay(500);
}