Introduction: Arduino Boss Key

About: software engineer from Shanghai China.

Have you ever been caught surfing during the work time? Have you ever tried to cover your mess when boss is coming? Have you ever dreamed of a gadget that could look you back? Now I have the answer with the help of the Arduino.

This is a very simple project that take advantage of the Arduino (mostly keyboard library) PIR sensor and the Autohotkey script.

Basically the PIR sensor tell the Arduino, the brain, that someone is coming towards you and Arduino trigger a key stroke to your laptop and the autohotkey script in the laptop listen to this key stroke and interprete to something else, in our case, bring your work i.e. excel file to the front.

Step 1: Parts and Materials

Parts list:

  • Arduino pro micro(to keep it small)
  • PIR sensor
  • USB cable
  • Jumper wires
  • elastic (optional)
  • computer or laptop (only support Windows OS)

The parts for this project should be under 50 RMB. All the parts should be easily to find in Taobao or ebay.

Step 2: Build the Circuit / Wire the Parts

the wiring is pretty straightforward.
  1. connect Arduino GND pin to the PIR sensor GND pin
  2. connect Arduino VCC pin to the PIR sensor VCC pin
  3. connect PIR sensor OUTPUT pin to Arduino digital pin 10 (I choose pin 10 because it's on the edge but you can pick whatever Digital pin you like)

Step 3: Write the Code (autohotkey)

AutoHotkey is a simple tool that allow you
to turn just about any action into a simple keyboard shortcut.

Here comes a introduction from lifehacker: However it's not required to learn this tool or scripting for this project, you can just download the script file and run it.

1. install authotkey from if you don't already have it.

2. create a working file, in our case, worklist.xls

3. download the script f3_work.ank here

4. double click the script to enable the script

The script map the F3 key to the action that trys to bring working file, worklist.xls in my case, to the front or open the file if it hasn't been opened.


IfWinExist Microsoft Excel - worklist






Run C:\worklist.xls

WinWait Microsoft Excel - worklist WinActivate



5. test the autohotkey script by pressing the F3 key. You should be able to see that file is being opened or is brought to the front. 
NOTE! you can choose whatever application or file you want to bring to the front. Just make sure to replace the "Microsoft Excel - worklist" as title with yours.

Step 4: Wirte Code (Arduino)

Here's my code. Feel free to tinker with
different parameters to suit your application, and comment if you'd like me to explain anything.

Install the Arduino IDE from if you don't already have it. Open up a new sketch and paste this code in. Compile it, upload it, and test it.

Keyboard Button test

For the Arduino Leonardo and Micro.

This example code is in the public domain.

modified by Addison yecheng wang

const int buttonPin = 10; // input pin for pushbutton
int previousButtonState = HIGH; // for checking the state of a pushButton

void setup() {
// make the pushButton pin an input:
pinMode(buttonPin, INPUT);
// initialize control over the keyboard:

void loop() {
// read the pushbutton:
int buttonState = digitalRead(buttonPin);
// if the button state has changed,
if ((buttonState != previousButtonState)
// and it's currently pressed:
&& (buttonState == HIGH)) {
// type out a message;

// save the current button state for comparison next time:
previousButtonState = buttonState;

Step 5: In Action

you can have a idea from the clip from above link

*** This is my first instructable. Please heart or comment on this one if you like, please ***