loading

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: http://lifehacker.com/316589/turn-any-action-into-.... 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 autohotkey.com 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.

f3::

IfWinExist Microsoft Excel - worklist

{

WinActivate

}

else

{

Run C:\worklist.xls

WinWait Microsoft Excel - worklist WinActivate

}

return

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 arduino.cc 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.

http://www.arduino.cc/en/Tutorial/KeyboardButton

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:
Keyboard.begin();
Serial.begin(9600);
}

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
Keyboard.press(KEY_F3);
delay(100);
Keyboard.releaseAll();
}

// save the current button state for comparison next time:
previousButtonState = buttonState;
//Serial.println(buttonState);
}


Step 5: In Action

http://v.youku.com/v_show/id_XNjc1NjkyNDY0.html

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 ***

<p>Copied your project to Arduino UNO: https://www.instructables.com/id/Porn-Key-based-on-the-Boss-Key</p>
<p>great</p>
<p>thanks for commenting :)</p>
<p>no problem. see a bunch of applications for it</p>
<p>Looks very interesting</p>

About This Instructable

3,888views

37favorites

License:

Bio: software engineer from Shanghai China.
More by eyecwan:wireless boss eye arduino boss key 
Add instructable to: