Introduction: Automatic Program Starter With Motion Sensor
Hi there! Welcome to my instructable!
I decided to make a distance sensor based application / program starter for my pc, since I'm too lazy to start the programs myself!
You will need the following parts:
Hardware:
- 3mm plywood (60cm x 60cm will do the job).
- A computer / laptop
- A lasercutter
- Arduino Ping Sensor (Buy Here)
- Arduino Uno (Buy Here)
- Breadboard
Software:
- A Java IDE
- Java JDK
- The Arduino Software
When you've got all this, why wait any longer?! Let's Go!
Step 1: Creating Your Arduino Case
In this step we'll need a lasercutter!
All you need is 3mm plywood and my caseplans!
(You can always create your own case if you want ofcourse).
Once you cut the parts out for the case you're already done with this step!
Attachments
Step 2: Getting the Programming Software!
To get started on your project I thought it was a good idea to start of with programming the software. I made it in Arduino and Java.
What you will need for this step are:
Java JDK (Click for the download page)
A Java IDE (Click for the download page)
Arduino IDE Software (Click for the download page)
So first of, download all the required software. When you've done this and installed everything open up your Arduino software.
Step 3: Setting Up the Arduino + Sensors
For this step I included an image of an electric circuit to make the connecting easier.
So in this step we are going to add the Ultrasonic Sensor (HC-SR04) to the arduino.
Pins:
- The VCC pin on the Sensor should go to a ground input on the Arduino.
- The GND Pin should go to the GND input on the Arduino
- The Trig pin goes to pin 11
- The Echo pin goes to pin 12
Step 4: Programming the Arduino
So for this step you obviously need the Arduino software, you can download the sourcecode that I used for my arduino on this page.
As soon as you started your Arduino software go over the following steps:
1. Connect your Arduino to your PC.
2. Click file -> open and then search the file you just downloaded that contains the Arduino sourcecode.
3. Try uploading it to your Arduino board.
If you want you can ofcourse check out how the sourcecode was written and how it works / edit it. But trust me, it works!
Attachments
Step 5: Programming the Java Software
This step you will need the programming IDE that you downloaded before.
You can download my java project so you don't have to go through the struggles of searching everything up! (It's an eclipse project.)
So if you are using eclipse (which is highly recommended for this project), you will have to place the downloaded project in your project folder of eclipse, you can find this project folder by clicking "File -> Switch Workspace". This will show the current folder that Eclipse is using to get all the projects from.
Now, you will need to click these things: "Right click on your project in the project explorer --> Build Path --> Configure Build Path" once you enter the "Configure Build Path" screen, click "Add External Jar" And search for your JSerialcomm File that you can find here: JSERIALCOMM DOWNLOAD.
Editing the code so it will open the right program:
In the image you see 4 marked lines, we will have to change those for you to let the program open the satisfied programs.
How: Search for your program folder (mostly located in "C:\Program Files (x86)") and look for the program's .exe file.
Like: skype.exe
After you did this, copy the filepath and past it in the line under the sentence: "Paste filepath down here:"
Also change the "HauppaugeCapture.exe" to your .exe filename.
This step is done now! You're doing a good job following everything up until here! Let's go to the next step.
Attachments
Step 6: Running and Testing Your Program!
We're in the final step!
We are gonna make a runnable program out of your Java source code.
It's really simple just follow these steps:
"Click file -> export -> Java -> Runnable Jar File -> Next"
A new screen will open, in this screen you will want to choose where you save your runnable file (i'd put it on your desktop).
And you also will want to choose the "Launch configuration". For this just choose the Main.java file.
Now click finish!
If everything went well you should have a .jar file on your desktop. Double click it and see for yourself if your programs start when you hold your hand in front of your sensor!