Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Include Library's
- #include <Wire.h>
- #include "LiquidCrystal.h"
- #include <IRremote.h>
- // Connect via i2c
- LiquidCrystal LCD(0);
- const uint16_t BUTTON_CHMI = 0xA25D;
- const uint16_t BUTTON_CHAN = 0x629D;
- const uint16_t BUTTON_CHPL = 0xE21D;
- const uint16_t BUTTON_PREV = 0x22DD;
- const uint16_t BUTTON_NEXT = 0x02FD;
- const uint16_t BUTTON_PLAY = 0xC23D;
- const uint16_t BUTTON_MINUS = 0xE01F;
- const uint16_t BUTTON_PLUS = 0xA857;
- const uint16_t BUTTON_BACK = 0x906F;
- const uint16_t BUTTON_0 = 0x6897;
- const uint16_t BUTTON_100p = 0x9876;
- const uint16_t BUTTON_200p = 0xB04F;
- const uint16_t BUTTON_1 = 0x30CF;
- const uint16_t BUTTON_2 = 0x18E7;
- const uint16_t BUTTON_3 = 0x7A85;
- const uint16_t BUTTON_4 = 0x10EF;
- const uint16_t BUTTON_5 = 0x38C7;
- const uint16_t BUTTON_6 = 0x5AA5;
- const uint16_t BUTTON_7 = 0x42BD;
- const uint16_t BUTTON_8 = 0x4AB5;
- const uint16_t BUTTON_9 = 0x52AD;
- int back;
- IRrecv IR(5);
- decode_results results;
- uint16_t lastCode = 0;
- void setup() {
- Serial.begin(9600);
- LCD.begin(16, 2); //Setup LCD display as 16 by 2
- LCD.setBacklight(HIGH);
- IR.enableIRIn();
- printAtPosition(4, 0, "ACE Home");
- printAtPosition(5, 1, "System");
- delay(700);
- clearLine(0);
- printAtPosition(5, 0, "Welkom");
- delay(700);
- clearLine(0);
- }
- void loop() {
- if (IR.decode(&results)) {
- uint16_t resultCode = (results.value & 0xFFFF);
- //De remote blijft 0XFFFFFFFF doorsturen als de knop blijft ingedrukt
- if (resultCode == 0xFFFF) {
- resultCode = lastCode;
- } else {
- lastCode = resultCode;
- }
- switch (resultCode) {
- case BUTTON_CHMI:
- back = 0;
- while(true){
- Serial.println("Temperture button pressed:");
- printAtPosition(2, 0, "Temperature: ");
- int x = 20;
- printAtPosition(2, 1, String(x));
- printAtPosition(10, 1, "+/-");
- IR.resume();
- Serial.println("Entering IRDECODE if");
- if (IR.decode(&results)) {
- Serial.println("Entered");
- uint16_t resultCode = (results.value & 0xFFFF);
- if (resultCode == 0xFFFF) {
- resultCode = lastCode;
- } else {
- lastCode = resultCode;
- }
- Serial.println("Entering Switch");
- switch (resultCode) {
- case BUTTON_PLUS:
- Serial.println("Plus pressed");
- x++;
- case BUTTON_MINUS:
- Serial.println("Minus pressed");
- x--;
- case BUTTON_BACK:
- Serial.println("Back pressed");
- back = 1;
- }
- if(back==1){break;};
- }
- }
- }
- IR.resume();
- }
- clearLine(0);
- }
- void printAtPosition(int x, int y, String text) {
- LCD.setCursor(x, y);
- LCD.print(text);
- }
- void clearLine(int y) {
- if (y == 1) {
- LCD.setCursor(0, 0);
- LCD.print(" ");
- }
- if (y == 2) {
- LCD.setCursor(0, 1);
- LCD.print(" ");
- }
- if (y == 0) {
- LCD.setCursor(0, 0);
- LCD.print(" ");
- LCD.setCursor(0, 1);
- LCD.print(" ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement