In: Electrical Engineering
Design and program an Arduino-based circuit that contains the
following items
- 1 Arduino Uno microcontroller.
- 1 IR remote control,
- 1 IR sensor
- 1 LCD 16x2 Display
- Any other components you find necessary.
The circuit will do the following:
- The circuit represents a 2-digit calculator.
- At start of operation, the LCD display should display “0” in line
2 of the LCD display.
- Pressing the On/Off button on the IR remote represents the
“Clear” button of the calculator, the VOL+ represents the “+”
button, the VOL- represents the “-” button, the |<<
represents the “X” button, the >>| represents the “/” button,
the EQ represents the “=” button, and the digits represent the
digits on the calculator.
- The system expects always the following sequence of keys:
[1] Clear,
[2] a digit (representing the 10s of first number),
[3] a digit (representing the ones of first number),
[4] an operation (+, -, X, /),
[5] a digit (representing the 10s of the second number),
[6] a digit (representing the ones of the second number),
[7] Equal
- After a correct sequence of presses is input (total of 7
presses), the display should display something like the following
on the two lines of the LCD:
“17+29= ”
“46 ”
- If a wrong sequence of buttons is pressed, for example: “Clear,
9, X, +, …. “, the system should display “ERROR” in the upper line
of the LCD.
- You may need to use the “#include <string.h>”
// include the library code:
#include <LiquidCrystal.h> //for LCD
#include <IRremote.h> //For IR Remote
// initialize the library with the numbers of the interface
pins
LiquidCrystal lcd( 7, 6, 5, 4, 3,2);
//IR interfacing pins
int RECV_PIN =8;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
//lcd.print("hello, world!");
}
void loop() {
char temp;
lcd.clear(); //step 1
//10th place---------------step 2
if (irrecv.decode(&results)){
value = results.value;
temp = GetLetters(value);
lcd.setCursor(1, 0);
lcd.print(temp);
//unit place--------------step 3
if (irrecv.decode(&results)){
value = results.value;
temp = GetLetters(value);
lcd.setCursor(1, 0);
lcd.print(temp);
//Sign--------------step 4
value = results.value;
temp = GetLetters(value);
lcd.setCursor(1, 0);
lcd.print(temp);
//2nd no 10th place--------------step 5
value = results.value;
temp = GetLetters(value);
lcd.setCursor(1, 0);
lcd.print(temp);
//2nd no unit place------------------step 6
value = results.value;
temp = GetLetters(value);
lcd.setCursor(1, 0);
lcd.print(temp);
//---------------------equal to---------
lcd.setCursor(0, 1);
value = results.value;
temp = GetLetters(value);
ans =(temp1,temp2)temp3(temp4,temp5);
if(value = "=")
lcd.print(ans);
}
char GetLetters(value)
{Serial.println(value);
switch(value){
case 12495: //Keypad button "1"
//set color red
return "1";
}
switch(value){
case -7177: //Keypad button "2"
//set color skyblue
return "2";
}
switch(value){
case 539: //Keypad button "3"
//set color pink
return "3";
}
switch(value){
case 25979: //Keypad button "4"
//set color light green
return "4";
}
//simillarly You Have to write a all Values Correasponding to the
key
irrecv.resume();
}
if you have any queries you can ask in the comment...