PC Remote Control Using Arduino Pro Micro

31,555

79

17

Introduction: PC Remote Control Using Arduino Pro Micro

About: I'm a graduate of Aircraft Engineering Technology (Hons) in Mechanical. I am passionate about energy, electric vehicles, gadgets, tools. My projects basically reflects my needs.

Hi I'm new to arduino and in the process of learning, like many I learn through tutorials, videos , 'ibles and by own experience.


Recently I wanted to use arduino Uno and IR remote to control VLC player. Unfortunately this didn't work well for me as Uno does not have built-in USB communication. For this reason it involves more steps to get the job done, like have to upload appropriate .hex file to the microcontroller to make it function as a HID (Human Interface Device). I went through different steps to make it possible (while reading many sources online) but I failed at it. I will attempt it again to understand further.

But for now...

I bought a Pro Micro and it is Arduino Leonardo compatible, since it has Atmega32U4, it can be used as HID mouse or keyboard. In order to control VLC I used this as a HID keyboard.

I went with Pro Micro instead of Arduino Leonardo is because of the size.

P.S: I followed these tutorials and more (sorry didn't make note of all of it),

http://tronixstuff.com/2011/03/30/tutorial-arduino...

https://www.instructables.com/id/USB-IR-Remote-Cont...

majority of the steps are similar however the coding is changed slightly to suite my remote and the functions I required. Lets get started

Step 1: Hardwares

1 x Pro Micro ATmega32U4 - US$7.80 - http://www.ebay.com/itm/Leonardo-Pro-Micro-ATmega...

Note: You can use Leonardo as well. I chose Pro Micro due to the small form factor.

1 x Micro USB Cable - parts bin.

1 x Small Breadboard - US$1.37 - http://www.ebay.com/itm/Mini-White-Solderless-Pro...

1 x Infra-red receiver 1838T - parts bin

1 x 5mm Led (Not essential, just to indicate when the signal is received. your choice of color) - parts bin

1 x 1k ohm - parts bin

1 x An IR remote - parts bin
Note: I have tested 3 different remotes they all worked so it doesn't matter as long as it is an IR remote.I chose this again for the small form

(Kindly correct me if I'm wrong)

4 x Jumper wires - parts bin

Note: parts bin refers to items I already had.

Step 2: Set Up Pro Micro

This was my first experience with Pro Micro and it was not smooth.
At first the computer did not recognize Pro Micro as a HID device and also it was not showing up in the Adruino IDE.

After some Google searches and disabling the digital signature thing from checking in windows 8, finally I was able to install the Pro Micro's driver and then it showed up.

But it didn't end there and tried to upload the code and it started to show errors in the Arduino IDE (sorry didn't take any snapshots).
Later used my Uno R3 as AVR ISP and burned the bootloader for the Pro Micro and Vola it worked fine.

I used this tutorial from sparkfun, my sincere thanks to them for the detailed tutorials.

https://learn.sparkfun.com/tutorials/pro-micro--fi...

Bootloader for Pro Micro and the drivers has been attached and also can be found in sparkfun website.

Step 3: Connections

Following the datasheet, the IR receiver is connected to the breadboard and using jumper wires to connect them to appropriate pins in the Pro Micro.
IR Receiver's output pin is connected to Pro Micro's pin 7 and powered by VCC pin (5V provided by the USB connection from the computer) and GND to GND pin.
LED is connected to pin 10 and GND.

Follow the pictures above to get clear. If you want a schematic diagram let me know in the comment & I'll upload as soon as I can.

Step 4: Getting the Code for the IR Remote Buttons

Unzip the Arduino-IRremote-master.zip file attached here and add it to the arduino library.
Upload the IRrecvDemo.ino from examples folder.
This will help to show the decimal code of the particular remote button in the serial monitor.

Note: The code below allows the serial monitor to display the code received from th IR receiver in Decimal hence DEC.
Serial.println(results.value, DEC);

If you want to use hexadecimal code just simply change the DEC to HEX, like

Serial.println(results.value, HEX);

Kindly stick to one of the code either DEC or HEX in all the codes.

It is helpful to write down which code belongs to which button to avoid confusion later. I used spreadsheet to write mine down and while coding you can just copy the appropriate button's code from the spreadsheet.


Step 5: Customizing the Code to Execute Funtions in Computer

http://arduino.cc/en/Reference/KeyboardModifiers#.... you can refer to this link on what coding should be used for specific keys in the keyboard.

http://www.asciitable.com/ you can also refer this link to get more codes for the keyboard buttons.

Use the code attached and make changes to the remote button codes.

This is a useful tutorial on how to use HID function

https://www.sparkfun.com/tutorials/337

You can add more functions as per your requirements.
To add more codes there are three places you have to insert the code.


I will show an example below:

Note:

Places with XXX means you can add your own name;

Places with YYY is the DEC/ HEX code from remote; and

Places with ZZZ has to changed according to the keys you need to press.

I'm just showing only what needs to be added to know where to insert them kindly look at the attached file.


1st Place

#define XXX YYY //use comments to make note of what the button does or refer it to the button on remote
#define XXX YYY

2nd Place

#define XXX_FUN Keyboard.press(ZZZ); Keyboard.press(ZZZ); Keyboard.write('ZZZ'); delay(100); Keyboard.releaseAll();
#define XXX_FUN Keyboard.write('ZZZ'); Keyboard.releaseAll();

Note: Keyboard.press --> presses the button such as arrow, ctrl, shift,..

Keyboard.write --> writes the characters a,b,c...

3rd Place

else if (results.value==XXX) {XXX_FUN; }
else if (results.value==XXX) {XXX_FUN; }

Any doubt kindly leave a comment and I'll help as much as I can.

Step 6: Customizing the Remote

The numbers in the remote didn't suit my need therefore I wanted to make my own names for the buttons.

1) I took a paper and pressed the sides of the remote to make the impression of it and cut along the impression.
2) I placed the paper on the remote and used my thumb nail around the buttons to capture the form.
3) Using a pen wrote the names/ symbols I wanted (according to the function it has been assigned in the code).
4) Used the plastic cover that came with the remote and inserted the label that I just made and sealed it.
5) A custom labelled remote is ready and can be changed any time I needed.

Step 7: Enjoy

You can the remote's button to press whatever keys you want to be pressed in a keyboard with appropriate code.
You can also add shortcut keys to programs and add that to your code, then you can launch the program by a single button in your remote. Like I have done in mine.(refer to the code in line #49 - IRrecvVIRE_HID.ino)

I have used my remote to control VLC player basically and the arrow keys and enter key so that I can select a movie using remote and also control VLC.

Show me what you have done with it.

And vote for me if you liked it!!!

Gadget Hacking and Accessories Contest

Participated in the
Gadget Hacking and Accessories Contest

Sensors Contest

Participated in the
Sensors Contest

Arduino Contest

Participated in the
Arduino Contest

Full Spectrum Laser Contest

Participated in the
Full Spectrum Laser Contest

1 Person Made This Project!

Recommendations

  • Make it Glow Contest

    Make it Glow Contest
  • First Time Author Contest

    First Time Author Contest
  • PCB Challenge

    PCB Challenge

17 Discussions

0
FusionN
FusionN

6 years ago on Introduction

Our company love use free and simple way as LiteManager app for Remote Control PC's from anywhere via Internet or local, it's very fast metod with any secure optionals.

0
Ghloo
Ghloo

Reply 10 months ago

Is it any better that SSH? I sincerely doubt it. :D

BTW, this is somewhat a DIY forum, right?

0
arielslyz
arielslyz

4 years ago

Hello, this arduino can remotely turn on a dekstop PC?

0
amorarun
amorarun

Reply 4 years ago

This works with infrared which has to be in-sight and has limited range. This cannot turn on laptop remotely. However to turn in your laptop remotely you will need to have an external wire connection for the laptop's power switch and use arduino with Ethernet module. I haven't done this personally but you should be able to find in Instructables website.

0
arielslyz
arielslyz

Reply 4 years ago

can you suggested what are the wire connection that I should have it?

Right now I trying build a project using arduino to turning on the desktop PC.

0
Ghloo
Ghloo

Reply 10 months ago

Why not use a Raspberry Pi with WoL? That could certainly be triggered with Arduino IR remote. Doing this in Arduino may not be too handy.

If I wanted to be brave, tough, I would have a look at thhe wires behing the on/off switch and would try to bypass them. To my understanding it is only a tactile switch so if you can use the Arduino to make the connection and on it is.

0
chelsear28
chelsear28

3 years ago

how can you move the cursor of the computer

0
Ghloo
Ghloo

Reply 10 months ago

Well, you can stick an accelerometer to your hand with an arduino and IR/BT/WiFi or use your phone and use its output to move the ouse around. Don`t they call it airmouse? ;o)

Technically, you could maybe assihn a command that moves the cursor to a certain position. In linux I believe i have things like xDotool, Actiona, etc for this...

0
amorarun
amorarun

Reply 3 years ago

Sorry you cannot move the cursor with this.

0
Ghloo
Ghloo

10 months ago

That is a very nice one, found it just as am accomplishing my own make (repurposing an old TV remote fom a TV card). But this came very handy.

May I suggest (as it is what I intend to do), link the three IR sensor wires to an audio jack/plug (these seem to me generally very useful for all sorts of sensors where you need low power and one signal). Actually, mine had 2.5mm jack and I decided to disassemble it with knife and some brute force ... while it would have been fine just to buy a 2.5mm socket for some peanuts. Nu vot, will need to figure out how the 3.5mm plug and socket are wired and redo the soldering. But then, why restrict oneself to VLC when those YT ads are sooo obtrusive...

0
TomášM81
TomášM81

3 years ago

Can this project be made with an other Arduino (Nano, to be precise), or is it Arduino Pro Micro-special?

0
Ghloo
Ghloo

Reply 10 months ago

No, it cannot, you need one that supports the USB HID feature.

0
amorarun
amorarun

Reply 3 years ago

You can use any Arduino. I have chosen Pro Micro for the form factor.

0
ArifSae
ArifSae

4 years ago

ok, i followed 2 tutorials, i think this one is more complete. Progressing :)

0
hal4512
hal4512

5 years ago

How can you use this library ?

atmega32U4 have no timer2 then an error occure when you compile this code

IRremote.cpp:266:3: note: in expansion of macro 'RESET_TIMER2'

thanks for responding.

0
amorarun
amorarun

5 years ago on Step 2

Thanks aakashsunkari, glad it helped.

0
aakashsunkari
aakashsunkari

5 years ago on Step 2

Thanks amorarun. Paragraph 3 in Step 2 REALLY helps. You NEED to do this, although Sparkfun claims you don't have to.