Communication
Description
Video Demonstration
Photos
Sketch
Schematic
Code
#include <LiquidCrystal.h>
#include <IRremote.h>
#define IR_RECEIVE_PIN 6
LiquidCrystal lcd(7,8,9,10,11,12);
void setup() {
lcd.begin(16,2);
lcd.print("Press a number");
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
Serial.begin(9600);
}
void loop() {
if (IrReceiver.decode()) {
//Print codes of each number
//Serial.print("Code: ");
//Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);
// stores the code corresponding to each button
unsigned long code = IrReceiver.decodedIRData.decodedRawData;
char number = getNumber(code);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("You just pressed: ");
lcd.setCursor(0,1);
lcd.print(number);
IrReceiver.resume();
}
}
char getNumber(unsigned long code) {
if (code == 0xF30CFF00) return '1';
if (code == 0xE718FF00) return '2';
if (code == 0xA15EFF00) return '3';
if (code == 0xF708FF00) return '4';
if (code == 0xE31CFF00) return '5';
if (code == 0xA55AFF00) return '6';
if (code == 0xBD42FF00) return '7';
if (code == 0xAD52FF00) return '8';
if (code == 0xB54AFF00) return '9';
if (code == 0xE916FF00) return '0';
}







No comments:
Post a Comment
Note: Only a member of this blog may post a comment.