(→USB to Serial adapter) |
(→References) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Often I wear my headphones at work and listen to music. Unfortunately I sit at a corner desk and my view of the office entrance is obstructed. This leads to people standing over my shoulder with out my knowing about it. This bugs me, so one day I decided to do something about it. | Often I wear my headphones at work and listen to music. Unfortunately I sit at a corner desk and my view of the office entrance is obstructed. This leads to people standing over my shoulder with out my knowing about it. This bugs me, so one day I decided to do something about it. | ||
− | == | + | == Disclaimer of Warranty == |
− | + | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. | |
+ | |||
+ | == Limitation of Liability == | ||
+ | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | ||
+ | |||
<span style="color:red">'''Use at your own risk!'''</span> | <span style="color:red">'''Use at your own risk!'''</span> | ||
Line 17: | Line 21: | ||
* Small (easily disguised in a picture frame or paperweight) | * Small (easily disguised in a picture frame or paperweight) | ||
* Reliable (Not to many false positives) | * Reliable (Not to many false positives) | ||
+ | |||
Line 52: | Line 57: | ||
=== SparkFun FTDI Adapter === | === SparkFun FTDI Adapter === | ||
− | I seriously considered using the [https://www.sparkfun.com/products/10275? LilyPad FTDI Adapter] available at SparkFun.com. <br> | + | I seriously considered using the [https://www.sparkfun.com/products/10275? LilyPad FTDI Adapter] available at [http://www.SparkFun.com SparkFun.com].<br> |
− | + | The adapter is reasonably priced and small enough to fit into my project box which means you can just run a USB cable directly to it.<br> | |
The plus to using this adapter is it has a dedicated 5v lead, meaning you don't need to draw power from the DTR pin.<br> | The plus to using this adapter is it has a dedicated 5v lead, meaning you don't need to draw power from the DTR pin.<br> | ||
Line 59: | Line 64: | ||
You will have to find/replace ''SensorPort.DsrHolding'' with ''SensorPort.CtsHolding''.<br> | You will have to find/replace ''SensorPort.DsrHolding'' with ''SensorPort.CtsHolding''.<br> | ||
You should also set "SensorPort.DtrEnable = False" since we won't be drawing power from it. | You should also set "SensorPort.DtrEnable = False" since we won't be drawing power from it. | ||
+ | |||
+ | |||
== Pictures == | == Pictures == | ||
Line 67: | Line 74: | ||
[[File:USBEye-9Pin a.jpg|360px]] | [[File:USBEye-9Pin a.jpg|360px]] | ||
[[File:USBEye-9Pin b.jpg|360px]] <br> | [[File:USBEye-9Pin b.jpg|360px]] <br> | ||
− | [[File:USBEye.jpg| | + | [[File:USBEye.jpg|603px]] |
[[File:USBEye-App.png]] <br> | [[File:USBEye-App.png]] <br> | ||
[[File:USBEye-TrayMenu.jpg]] | [[File:USBEye-TrayMenu.jpg]] | ||
[[File:USBEye-MoDet.jpg]] | [[File:USBEye-MoDet.jpg]] | ||
− | |||
− | |||
== .NET Code == | == .NET Code == | ||
Line 81: | Line 86: | ||
That said, I'm providing the code for others to use or even expand on to their liking. | That said, I'm providing the code for others to use or even expand on to their liking. | ||
− | [[Media:USBEye | + | [[Media:USBEye-source.zip|USBEye-source.zip]] |
=== Executable === | === Executable === | ||
[[Media:USBEye.zip|USBEye.zip]] | [[Media:USBEye.zip|USBEye.zip]] | ||
+ | |||
+ | |||
+ | === Changelog === | ||
+ | v1.1.0.1 (3/29/2013) | ||
+ | * Added feature to mute audio alerts when workstation is locked | ||
+ | |||
+ | |||
+ | v1.1 (3/5/2013) | ||
+ | * Added command line arguement | ||
+ | ** /test Displays testing finctions | ||
+ | ** /? Displays usage and help | ||
+ | |||
+ | * Added ability to run an external application. (This can be used to create a log file, or trigger a Webcam to take a picture.) <br> | ||
+ | '''''Note:''' If you need to pass arguments to the external application then you should wrap them into a batch file.'' | ||
+ | |||
+ | |||
+ | V1.0 (2/22/2013) | ||
+ | * Initial realease | ||
+ | |||
+ | == Other Stuff == | ||
+ | === CommandCam === | ||
+ | I found a handy command line utility called [http://http://batchloaf.wordpress.com/commandcam CommandCam] that will capture an image from your PC's webcam. <br> | ||
+ | This batch file will run CommandCam and create a file named by timedate stamp. Then displays the image. <br> | ||
+ | You will have to modify the paths (C:\Temp) to suit your needs. | ||
+ | |||
+ | @echo Off | ||
+ | |||
+ | SET HHMMSS=%time::=% | ||
+ | SET DDMMYY=%date:~4,6%%date:~12,2% | ||
+ | C:\Temp\CommandCam.exe /filename C:\Temp\%DDMMYY:/=%%HHMMSS:~0,6%.bmp | ||
+ | C:\Temp\%DDMMYY:/=%%HHMMSS:~0,6%.bmp | ||
+ | |||
== References == | == References == | ||
+ | CommandCam <br> | ||
+ | http://http://batchloaf.wordpress.com/commandcam | ||
+ | |||
+ | |||
+ | Altoids | ||
+ | http://www.altoids.com | ||
− | [[Category: | + | [[Category:Software_Development]] |
Latest revision as of 23:40, 25 August 2013
Often I wear my headphones at work and listen to music. Unfortunately I sit at a corner desk and my view of the office entrance is obstructed. This leads to people standing over my shoulder with out my knowing about it. This bugs me, so one day I decided to do something about it.
Contents
Disclaimer of Warranty
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
Limitation of Liability
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Use at your own risk!
Goals
While I could very well have placed a mirror on my desk or monitor I decided that it would be nice when someone walks in to receive some form of notification in the form of a balloon notification, audible tone, or a screen flash. This requires a motion sensor that can interface with my PC.
Requirements
- Inexpensive
- Simple to build
- Small (easily disguised in a picture frame or paperweight)
- Reliable (Not to many false positives)
Design
After doing some research I decided a PIR (Passive Infrared) sensor would be sufficient. I found this one (Parallax PIR Rev.B) which is widely available at your local Radio Shack.
Parts List
PIR Sensor
Catalog #: 276-135
1/8" Stereo Panel-Mount Audio Jack (2-Pack)
Catalog #: 274-249
9-Pin Female Solder D-Sub Connector
Catalog #: 276-1538
9-Position Shielded Connector Hood
Catalog #: 276-1513
Wire: I used strands of wire from CAT5 cable I had laying around for the internal wiring. I also used an old headphone cable for the link cable between the Serial port to the project box (a.k.a ALTOIDS can).
USB to Serial adapter
The USB to Serial Adapter is optional, assuming you have a serial port available on your PC.
If you don't have a serial port (few laptops have serial ports any more), then you will need to use an adapter.
I use one based on the Prolific PL2303 chipset, available here
Other USB adapters should also work but I haven't tested any other adapters so your results may vary.
SparkFun FTDI Adapter
I seriously considered using the LilyPad FTDI Adapter available at SparkFun.com.
The adapter is reasonably priced and small enough to fit into my project box which means you can just run a USB cable directly to it.
The plus to using this adapter is it has a dedicated 5v lead, meaning you don't need to draw power from the DTR pin.
If you use this board, you will have to change the source code.
You will have to find/replace SensorPort.DsrHolding with SensorPort.CtsHolding.
You should also set "SensorPort.DtrEnable = False" since we won't be drawing power from it.
Pictures
.NET Code
I decided to use the DSR pin on the Serial port because VB.NET has the an Event Handler that deals with pinchanged events.
Specifically on the System.IO.Ports.SerialPort class there is the DSRHolding property that will return a True/False based on whether the DSR pin is receiving current or not.
Please keep in mind that programming is not my profession nor even a hobby of mine. I'm almost certain there are better / more efficient ways of coding this application.
That said, I'm providing the code for others to use or even expand on to their liking.
Executable
Changelog
v1.1.0.1 (3/29/2013)
- Added feature to mute audio alerts when workstation is locked
v1.1 (3/5/2013)
- Added command line arguement
- /test Displays testing finctions
- /? Displays usage and help
- Added ability to run an external application. (This can be used to create a log file, or trigger a Webcam to take a picture.)
Note: If you need to pass arguments to the external application then you should wrap them into a batch file.
V1.0 (2/22/2013)
- Initial realease
Other Stuff
CommandCam
I found a handy command line utility called CommandCam that will capture an image from your PC's webcam.
This batch file will run CommandCam and create a file named by timedate stamp. Then displays the image.
You will have to modify the paths (C:\Temp) to suit your needs.
@echo Off SET HHMMSS=%time::=% SET DDMMYY=%date:~4,6%%date:~12,2% C:\Temp\CommandCam.exe /filename C:\Temp\%DDMMYY:/=%%HHMMSS:~0,6%.bmp C:\Temp\%DDMMYY:/=%%HHMMSS:~0,6%.bmp
References
CommandCam
http://http://batchloaf.wordpress.com/commandcam
Altoids
http://www.altoids.com