Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dragonkeepers Ardunio IR remote and CPU/RAM monitor for XBMC
- --code----
- #include <IRremote.h>
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
- int RECV_PIN = 12;
- int STATUS_PIN = A5;
- const unsigned int MAX_INPUT = 8;
- IRrecv irrecv(RECV_PIN);
- decode_results results;
- void setup()
- {
- Serial.begin(9600);
- irrecv.enableIRIn();
- pinMode(STATUS_PIN, OUTPUT);
- lcd.begin(16, 2);
- lcd.setCursor(0, 0);
- lcd.print("X B M C - Remote");
- }
- int codeType = -1;
- unsigned long codeValue;
- unsigned int rawCodes[RAWBUF];
- int codeLen;
- int toggle = 0;
- void storeCode(decode_results *results) {
- codeValue = results->value;
- codeLen = results->bits;
- codeType = results->decode_type;
- int count = results->rawlen;
- if (codeType == UNKNOWN) {
- codeLen = results->rawlen - 1;
- for (int i = 1; i <= codeLen; i++) {
- if (i % 2) {
- // Mark
- rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
- }
- else {
- // Space
- rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
- }
- }
- }
- else {
- if (codeType == NEC) {
- // if (results->value == REPEAT) {
- // // Don't record a NEC repeat value as that's useless.
- // return;
- // }
- }
- else if (codeType == SONY) {
- }
- else if (codeType == RC5) {
- }
- else if (codeType == RC6) {
- }
- else {
- }
- Serial.println(results->value, HEX);
- if (codeValue == 0x61D610EF) {
- // Down
- Keyboard.press(0xD9);
- Keyboard.release(0xD9);
- }
- if (codeValue == 0x61D640BF) {
- // UP
- Keyboard.press(0xDA);
- Keyboard.release(0xDA);
- }
- if (codeValue == 0x61D620DF) {
- // Left");
- Keyboard.press(0xD8);
- Keyboard.release(0xD8);
- }
- if (codeValue == 0x61D6609F) {
- // Right");
- Keyboard.press(0xD7);
- Keyboard.release(0xD7);
- }
- if (codeValue == 0x61D6A05F) {
- // Select");
- Keyboard.press(0xB0);
- Keyboard.release(0xB0);
- }
- if (codeValue == 0x61D630CF) {
- //"Vol Up");
- Keyboard.press('+');
- Keyboard.release('+');
- }
- if (codeValue == 0x61D618E7) {
- // Vol Down");
- Keyboard.press('-');
- Keyboard.release('-');
- }
- if (codeValue == 0x61D6708F) {
- //Stop");
- Keyboard.press('x');
- Keyboard.release('x');
- }
- if (codeValue == 0x61D67887) {
- // Play/Pause");
- Keyboard.press(' ');
- Keyboard.release(' ');
- }
- if (codeValue == 0x61D648B7) {
- //Power");
- Keyboard.press('s');
- Keyboard.release('s');
- }
- if (codeValue == 0x61D6C837) {
- //Mute");
- Keyboard.press(0xC9);
- Keyboard.release(0xC9);
- }
- if (codeValue == 0x61D650AF) {
- //Back");
- Keyboard.press(0xB2);
- Keyboard.release(0xB2);
- }
- if (codeValue == 0x61D6D827) {
- //Subs");
- Keyboard.press('t');
- Keyboard.release('t');
- }
- if (codeValue == 0x61D658A7) {
- //Display");
- Keyboard.press(0xB3);
- Keyboard.release(0xB3);
- }
- if (codeValue == 0x61D6D02F) {
- //KeyStart");
- Keyboard.begin();
- }
- if (codeValue == 0x61D6A857) {
- //KeyEnd");
- Keyboard.end();
- }
- ///remote2 :
- if (codeValue == 0x8061F759) {
- //Down");
- Keyboard.press(0xD9);
- Keyboard.release(0xD9);
- }
- if (codeValue == 0x80617758) {
- //UP");
- Keyboard.press(0xDA);
- Keyboard.release(0xDA);
- }
- if (codeValue == 0x8061775A) {
- //Left");
- Keyboard.press(0xD8);
- Keyboard.release(0xD8);
- }
- if (codeValue == 0x8061775B) {
- //Right");
- Keyboard.press(0xD7);
- Keyboard.release(0xD7);
- }
- if (codeValue == 0x8061775C) {
- //Select");
- Keyboard.press(0xB0);
- Keyboard.release(0xB0);
- }
- if (codeValue == 0x8061F710) {
- //Vol Up");
- Keyboard.press('+');
- Keyboard.release('+');
- }
- if (codeValue == 0x80617711) {
- //Vol Down");
- Keyboard.press('-');
- Keyboard.release('-');
- }
- if (codeValue == 0x8061772C) {
- //Play/Pause");
- Keyboard.press(' ');
- Keyboard.release(' ');
- }
- if (codeValue == 0x8061F738) {
- //Power");
- Keyboard.press('s');
- Keyboard.release('s');
- }
- if (codeValue == 0x8061770D) {
- //Mute");
- Keyboard.press(0xC9);
- Keyboard.release(0xC9);
- }
- if (codeValue == 0x80617F83) {
- //Back");
- Keyboard.press(0xB2);
- Keyboard.release(0xB2);
- }
- if (codeValue == 0x80617754) {
- //Subs");
- Keyboard.press('t');
- Keyboard.release('t');
- }
- if (codeValue == 0x80617771) {
- //Display");
- Keyboard.press(0xB3);
- Keyboard.release(0xB3);
- }
- }
- }
- void loop() {
- if (irrecv.decode(&results)) {
- digitalWrite(STATUS_PIN, HIGH);
- storeCode(&results);
- irrecv.resume(); // resume receiver
- digitalWrite(STATUS_PIN, LOW);
- }
- String content = "";
- char character;
- while(Serial.available()) {
- character = Serial.read();
- content.concat(character);
- }
- //------------------------------------------------Edit \/
- if (content != "") {
- if (content == "`") {
- content = "";
- lcd.setCursor(0,1);
- }
- if (content == "*") {
- content = "";
- lcd.setCursor(0,0);
- }
- //-------------------------------------------------------/\
- Serial.println(content);
- lcd.print(content);
- delay(500);
- lcd.clear();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement