Hello…I have an arduino mega ,an IR remote control ,a lcd and an IR reciever to recieve data from IR remote control.
So I have a password and I have to find it by pressing the buttons of IR remote control.
Here is the code to understand what I’m doing:
#include <IRremote.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int RECV_PIN = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned list[3] = {}; //array to add hex numbers... the correct password is: 351 <---
int num_of_digits = 0;
int pos = 10; //position in lcd...
void setup()
{
Serial.begin(9600);
lcd.begin();
lcd.backlight();
lcd.setCursor(0, 0);
irrecv.enableIRIn();
irrecv.blink13(true);
lcd.print("UNLOCK SYSTEM: ");
lcd.setCursor(0, 1);
lcd.print("PASSWORD> ");
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume();//number 0 1 2 3 4 5 6 7
if (results.value == 0xFF9867 || results.value == 0xFFA25D || results.value == 0xFF629D || results.value == 0xFFE21D || results.value == 0xFF22DD || results.value == 0xFF02FD || results.value == 0xFFC23D || results.value == 0xFFE01F)
{
Serial.println(results.value, HEX);
lcd.setCursor(pos, 1);
lcd.print("*");
list[num_of_digits] = results.value;
num_of_digits++;
pos++;
}
if (num_of_digits == 3)
{ //number 3 5 1
if (list[0] == 0xFFE21D && list[1] == 0xFF02FD && list[2] == 0xFFA25D)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Correct");
}
if (list[0] != 0xFFE21D || list[1] != 0xFF02FD || list[2] != 0xFFA25D)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Wrong");
num_of_digits = 0;
pos = 10;
delay(1000);
lcd.clear();
lcd.print("UNLOCK SYSTEM: ");
lcd.setCursor(0, 1);
lcd.print("PASSWORD> ");
}
}
}
}
In serial monitor ,I get this message for number 3,5 and 1 respectively:
FFE21D //number 3
FF02FD //number 5
FFA25D //number 1 ,but in my code I have 0xFFE21D etc…(maybe this is the problem or the list I
made to save the data )
So,every 3 times I press the numbers 3,5,1(to find the correct code) ,I get the answer “Wrong”…
I can not put on FFE21D ,beacuse ,I get an error.
Can anyone help me about this problem,because I stack and I can’t continue the project!!!
Thanks.