Dear forum members
Im really struggling at the moment, for a project i need to “connect” to Arduino’s to each other with an IR connection.
It comes down to this:
Moisture sensor gives a value.
That value needs to start one of 5 if statements with an iR code.
The second Arduino needs to recognize the iR code and make text appear on the LCD.
The problem is in the connection part, i tried using existing sony IR commands, with an if statement on the second Arduino, but no luck so far.
I would really like some tips.
The code I have so far:
#include <IRremote.h>
IRsend irsend;
int mostureSensor = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(mostureSensor);
Serial.println(sensorValue);
if (sensorValue >= 820)
{ irsend;
//Really Dry
}
else if (sensorValue >= 615 && sensorValue < 820)
{ irsend.sendSony(0xa90, 12);
//Dry
}
else if (sensorValue >= 410 && sensorValue < 615)
{ irsend.sendSony(0x9746d, 20);
//good
}
else if (sensorValue >= 250 && sensorValue < 410)
{
//Wet
}
else if (sensorValue >= 0 && sensorValue < 250)
{
//Really Wet
}
delay(1000);
}
SECOND Arduino CODE:
#include <IRremote.h>
IRsend irsend;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int RECV_PIN = 13;
IRrecv irrecv(RECV_PIN);
void setup() {
// put your setup code here, to run once:
irrecv.enableIRIn();
}
void loop() {
if(irrecv.decode(&results)) //this checks to see if a code has been received
if (results.value == 0x68B92);{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Dry Give Water");
}
irrecv.resume(); // Receive the next value
}