Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Arduino_Scuola
Published © GPL3+

Control Your Computer With A Remote Control

Learn how to control your computer remotely with a remote control.

BeginnerFull instructions provided1 hour15,228
Control Your Computer With A Remote Control

Things used in this project

Hardware components

Arduino Micro
Arduino Micro
×1
IR Receiver Tsop2238 - 38 KHZ
×1
10 Red LED 5mm
×1
10 100 ohm 1/4w resistor
×1
470 ohm resistors 10x
×1

Story

Read more

Code

Code snippet #1

Arduino
/* VLC IR REMOTE CONTROLLER
 *
 * Control your computer while using VLC
 * with any IR remote controller you want.
 *
 * Created by
 * Angelo Scialabba
 * Arturo Guadalupi
 *
 * Based on IRremote library by Ken Shirriff  
 */
 
#include <irremote.h>
int RECV_PIN = 11;  //IR receiver connected on pin 11
int LED_PIN = 2;
int commandExecuted = 0;
//Change these values to match data sent by your remote control
 
/*-----COMMANDS------*/
const long play = 0x800F046E;  
const long volumeUp= 0x800F0410;
const long volumeDown= 0x800F8411;
const long forward= 0x800F8414;
const long backward= 0x800F0415;
const long mute= 0x800F040E;
/*-----END COMMANDS------*/
 

IRrecv irrecv(RECV_PIN);  //initialize IR library on RECV_PIN
decode_results results;   //received data will be stored here
 
void setup()
{
  pinMode(LED_PIN,OUTPUT); 
  digitalWrite(LED_PIN,LOW);
  irrecv.enableIRIn();  // Start the receiver
  Keyboard.begin();  //Start arduino as keyboard
}
 
void loop() {
  if (irrecv.decode(&results)) {
    switch(results.value){  //fetch received data
    case play:
      Keyboard.press(' ');
      commandExecuted = 1;
      break;
    case volumeUp:
      Keyboard.press(KEY_LEFT_CTRL);
      Keyboard.press(KEY_UP_ARROW);
      commandExecuted = 1;
      break;
    case volumeDown:
      Keyboard.press(KEY_LEFT_CTRL);
      Keyboard.press(KEY_DOWN_ARROW);
      commandExecuted = 1;
      break;
    case forward:
      Keyboard.press(KEY_LEFT_CTRL);
      Keyboard.press(KEY_RIGHT_ARROW);
      commandExecuted = 1;
      break;
    case backward:
      Keyboard.press(KEY_LEFT_CTRL);
      Keyboard.press(KEY_LEFT_ARROW);
      commandExecuted = 1;
      break;
    case mute:
      Keyboard.press('m');
      commandExecuted = 1;
      break;
    }
    if ( commandExecuted == 1) {   //turn on the LED a command was executed
       digitalWrite(LED_PIN,HIGH);
       commandExecuted = 0;        // reset the flag value
    }
    delay(100);
    digitalWrite(LED_PIN,LOW);
    Keyboard.releaseAll();
 
    irrecv.resume(); // Receive the next value
  }
}

Code snippet #3

Arduino
const int nextSlide = 0x0x800F046E  // this line need to be inserted at the begin of the sketch

//this case statement needs to be added inside the switch construct
case nextSlide:
      Keyboard.press(KEY_RIGHT_ARROW);
      commandExecuted = 1;
      break;

Github

https://github.com/shirriff/Arduino-IRremote.

Credits

Arduino_Scuola
32 projects • 155 followers
Contact

Comments

Please log in or sign up to comment.