I had seen a video on Instagram where an employee in an office is playing a game on his work computer, when their boss walks in. The employee had installed a trip-wire sensor to the door frame, which when triggered, seemed to display the Windows desktop. This promped an idea. I had the thought of some cool covert macro-pad before, but no neat way to house the components. Because an employee at my workplace had purchased a 3D printer for application with a project requested by the company owner, I was able to use the printer(for the first time, if you're looking at my print quality...) to print a case I designed using TinkerCad.
Defcon Switch Panel
New design for this project coming soon! Here's the original:
Once I printed the container, I was ready to house a few push-buttons, a toggle switch, and an Arduino. I threaded the buttons into place on the rail of the defcon box, and tightened down the hex nuts, ensuring that the wire terminals were in line with each other. I slid the toggle switch into place, so that the positive and negative terminals were in line with the positive and negative terminals on the buttons.
I cut one longer wire to use as the ground, and held it up to the button terminals to ensure there's enough length to go all the way to the switch at the end. On the ground wire, I marked where the terminal screws would screw down to the wire, and cut away the rubber insultation so that the single ground line could be shared in a seriers, with the end of the wire wrapped around the negative terminal on the toggle switch. Then, I cut three shorter wires, and tightened one end of each to the positve terminals on the buttons for the digital I/O pins. I cut one more short wire for the toggle switch's positve terminal.
The three red wires pictured here were going to be the power lines for three LEDs that I made holes for in the front of the Defcon box. Unfortunately, I was just shy of having enough room to slide the rail into the box, while clearing the leads on the LEDs. Had to remove them from my finished box. I could go back and slightly change the size of the model, but I may revisit it one day for other applications. With the buttons wired, all I really needed to do was upload the code!
Code
Demonstration
The code is written so that the push-buttons won't be read for presses until the toggle switch has been flipped, "arming" the device.
Here's how I coded my buttons. Keep in mind that these files and locations may be specific to my computer. Therefore, you'll need to make those adjustments to the code if you are wanting to set your own functions.
Button 1:
- Continuously checks and updates the state of two variables. 'dflag' and 'lastdflag'. When the arduino is powered on, dflag is set to '0'. When the button is pressed, it checks 'lastdflag' to make sure it is not the same as 'dflag'. It then uses the variables to decide which action to take in a switch...case statement.
- If case 0, the keypress combination of the Windows/GUI key, the control key, and the right arrow are pressed. This switches to the second Windows Desktop. If case 1, the Windows/GUI key, the control key, and the left arrow key are pressed, switching back to desktop 1.
Button 2:
- Opens the run prompt with keypress combination of the Windows/GUI key + 'r',
- "Println", entering the file location of the Discord shortcut.
- Sends an 'Enter' keypress to run the location, opening Discord.
Button 3:
- Opens the run prompt with keypress combination of the Windows/GUI key + 'r',
- "Println", entering the file location of the Wow.wav file
- Sends an 'Enter' keypress to run the location, opening the wav file with the Windows' default audio application.