IR Remote Control for Presentation PC
This is a simple project that will allow you to remotely control the display of presentations on your computer.
Components and supplies
1
Pro Micro - 5V/16MHz
1
Mini Infrared IR Wireless Remote Control Sensor Module Kits for Arduino
Apps and platforms
1
Arduino IDE
Project description
Code
Code
c_cpp
1// Remote Control For Presentation PC 2// Module Pro Micro (AT MEGA 32U4) 16MHz 3// NEC protocol only 4 5// Author: Piotr Sylwesiuk 6// https://plus.google.com/109581799567307387329 7 8// IR Remote library from https://github.com/z3t0/Arduino-IRremote 9// HID library from https://github.com/NicoHood/HID 10 11#include <HID-Project.h> 12#include <HID-Settings.h> 13 14#include <boarddefs.h> 15#include <IRremote.h> 16#include <IRremoteInt.h> 17 18uint8_t ir_code(); 19 20// Infrared remote control 21#define IR_ADDR 0x00FF // Address 22// used keys 23#define IR_KEY_3 0xE2 // Vol+ 24#define IR_KEY_6 0xC2 // Vol- 25#define IR_KEY_9 0x90 // Mute 26#define IR_KEY_0 0x98 // Play/Pause 27#define IR_KEY_STAR 0x68 // ESC 28#define IR_KEY_HASH 0xB0 // Shift F5 29#define IR_KEY_UP_ARROW 0x18 // Arrow Up 30#define IR_KEY_DOWN_ARROW 0x4A // Arrow Down 31#define IR_KEY_RIGHT_ARROW 0x5A // Arrow Right 32#define IR_KEY_LEFT_ARROW 0x10 // Arrow Left 33#define IR_KEY_OK 0x38 // F5 34 35// IR Receiver 36#define IR_RECEIVER_PIN A2 37 38IRrecv irrecv(IR_RECEIVER_PIN); 39 40void setup() { 41 // put your setup code here, to run once: 42 43 // Initializing the infrared receiver 44 irrecv.enableIRIn(); 45 irrecv.blink13(false); 46 47 // Initializing control over the keyboard 48 Keyboard.begin(); 49 Consumer.begin(); 50} 51 52void loop() { 53 // put your main code here, to run repeatedly: 54 55 switch(ir_code()){ 56 case IR_KEY_UP_ARROW : Keyboard.write(KEY_UP_ARROW); break; 57 case IR_KEY_DOWN_ARROW : Keyboard.write(KEY_DOWN_ARROW); break; 58 case IR_KEY_RIGHT_ARROW : Keyboard.write(KEY_RIGHT_ARROW); break; 59 case IR_KEY_LEFT_ARROW : Keyboard.write(KEY_LEFT_ARROW); break; 60 case IR_KEY_STAR : Keyboard.write(KEY_ESC); break; 61 62 // Shift F5 63 case IR_KEY_HASH : Keyboard.press(KEY_LEFT_SHIFT); 64 Keyboard.write(KEY_F5); 65 Keyboard.release(KEY_LEFT_SHIFT); break; 66 67 case IR_KEY_OK : Keyboard.write(KEY_F5); break; 68 case IR_KEY_9 : Consumer.write(MEDIA_VOLUME_MUTE); break; 69 case IR_KEY_3 : Consumer.write(MEDIA_VOLUME_UP); break; 70 case IR_KEY_6 : Consumer.write(MEDIA_VOLUME_DOWN); break; 71 case IR_KEY_0 : Consumer.write(MEDIA_PLAY_PAUSE); break; 72 } 73} 74 75// ---------------------------------------------------------- 76uint8_t ir_code() { 77 decode_results irResults; // Here we store the results 78 uint16_t irCode = 0; 79 static uint8_t irTmp = 0; 80 81 if (irrecv.decode(&irResults)) { 82 if ((irResults.decode_type == NEC) && (!irResults.overflow)) { 83 if ((irResults.bits == 32) && (((irResults.value & 0xffff0000)>>16) == IR_ADDR)) { 84 irCode = irResults.value & 0x0000ffff; 85 irTmp = (~(irCode & 0x00ff))& 0x00ff; 86 irCode >>= 8; 87 if (!(irCode == irTmp)) irCode = irTmp = 0; 88 89 // Recognition of the code repetition of the pressed remote control button. 90 } else if ((irResults.bits == 0) && (irResults.value == 0xffffffff) && (irTmp != 0)) { 91 92 // Autorepeat for Vol+ and Vol- (IR_KEY_3 and IR_KEY_6) 93 if((irTmp==IR_KEY_3)||(irTmp==IR_KEY_6)) irCode=irTmp; else irCode = 0xff; 94 95 } else irCode = irTmp = 0; 96 } else irCode = irTmp = 0; 97 irrecv.resume(); // Prepare for the next value 98 return (irCode); 99 } else { 100 irCode = 0; 101 return (irCode); 102 } 103} 104 105 106
Downloadable files
Wiring diagram
Wiring diagram

Wiring diagram
Wiring diagram

Comments
Only logged in users can leave comments