/*
LiquidCrystal Library - Hello World
www.elegoo.com 2016.12.9 Lesson 22
Library originally added 18 Apr 2008 by David A. Mellis
library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009 by Tom Igoe
modified 22 Nov 2010 by Tom Igoe
modified 14 Nov 2022 by John Lutz
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
16x2 LCD display. The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver.
There are many of them out there, and you can usually tell them by the 16-pin interface.
pin wiring http://wiki.sunfounder.cc/index.php?title=LCD1602_Module
LCD Pin to arduino pin color
RS digital 7 brown
Enable digital 8 orange
D4 digital 9 yellow
D5 digital 10 green
D6 digital 11 blue
D7 digital 12 pink
R/W ground black
VSS ground black
VCC / VDD 5 V red
A 3.3 V
K GND
50K resistor [potentiometer]:
ends to +5V and ground
wiper to LCD VO pin (pin 3)
*/
#include <LiquidCrystal.h> // include the library code:
#include "IRremote.h"
#define pin_receiver 2 // Signal Pin of IR receiver to Arduino Digital Pin XX
LiquidCrystal lcd(7, 8, 9, 10, 11, 12); // initialize the library with the numbers of the interface pins
IRrecv receiver(pin_receiver); /*-----( Declare objects )-----*/
void setup() {
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.print("<press a button>"); // Print a message to the LCD.
receiver.enableIRIn(); // Start the IR receiver
} // END void setup
void loop() {
if (receiver.decode()) {
translateIR_wokwi(); // use wokwi for simulator and elegoo for real
receiver.resume(); // Receive the next value
}
} // END void loop
// --------<( BEGIN translateIR Function )>--------
void translateIR_elegoo() // Takes command based on IR code received
{
switch (receiver.decodedIRData.command) {
case 69: lcdPrint("POWER"); break;
case 70: lcdPrint("VOL +"); break;
case 71: lcdPrint("FUNC / STOP"); break;
case 68: lcdPrint("FAST BACK"); break;
case 64: lcdPrint("PLAY | PAUSE"); break;
case 67: lcdPrint("FAST FWRD"); break;
case 7: lcdPrint("DOWN"); break;
case 21: lcdPrint("VOL -"); break;
case 9: lcdPrint("UP"); break;
case 22: lcdPrint("0"); break;
case 25: lcdPrint("EQ"); break;
case 13: lcdPrint("ST / REPT"); break;
case 12: lcdPrint("1"); break;
case 24: lcdPrint("2"); break;
case 94: lcdPrint("3"); break;
case 8: lcdPrint("4"); break;
case 28: lcdPrint("5"); break;
case 90: lcdPrint("6"); break;
case 66: lcdPrint("7"); break;
case 82: lcdPrint("8"); break;
case 74: lcdPrint("9"); break;
default:
lcd.clear();
lcd.print(receiver.decodedIRData.command);
lcd.print(" other button");
}
}
void lcdPrint(char* text)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(text); // what the button does
lcd.setCursor(0, 1);
lcd.print("code: ");
lcd.print(receiver.decodedIRData.command);
}
// --------<( BEGIN translateIR Function )>--------
void translateIR_wokwi() { // takes action based on IR code received, describing Remote IR codes
switch (receiver.decodedIRData.command) {
case 162: lcdPrint("POWER"); break;
case 226: lcdPrint("MENU"); break;
case 34: lcdPrint("TEST"); break;
case 2: lcdPrint("PLUS"); break;
case 194: lcdPrint("BACK"); break;
case 224: lcdPrint("PREV."); break;
case 168: lcdPrint("PLAY"); break;
case 144: lcdPrint("NEXT"); break;
case 104: lcdPrint("num: 0"); break;
case 152: lcdPrint("MINUS"); break;
case 176: lcdPrint("key: C"); break;
case 48: lcdPrint("num: 1"); break;
case 24: lcdPrint("num: 2"); break;
case 122: lcdPrint("num: 3"); break;
case 16: lcdPrint("num: 4"); break;
case 56: lcdPrint("num: 5"); break;
case 90: lcdPrint("num: 6"); break;
case 66: lcdPrint("num: 7"); break;
case 74: lcdPrint("num: 8"); break;
case 82: lcdPrint("num: 9"); break;
default:
lcd.clear();
lcd.print(receiver.decodedIRData.command);
lcd.print(" other button");
}
}
// --------<( END translateIR Function )>--------