Sometimes it is necessary to automatically close windows on a computer when someone enters a room to protect privacy or to avoid accidental disclosure of important information. In this article, we will create an Arduino-based device that will detect motion using a PIR sensor and automatically close open windows on the computer.
Arduino (Uno, Nano or other compatible controller)
PIR motion sensor (e.g. HC-SR501)
Resistors and conductors for connections
USB cable for connecting Arduino to a computer
Computer with Arduino IDE and AutoHotkey installed
AutoHotkey (to create a script to close windows)
Software for communicating Arduino with a computer (for example, Serial Monitor or a special script in Python)
A PIR sensor is a small sensor that “sees” movement. Here’s how to connect it:
Connect VCC on the sensor to 5V on the Arduino (this is power).
Connect the GND on the sensor to the GND on the Arduino (this is ground).
Connect the OUT on the sensor to D2 on the Arduino (this is the pin we get the signal through).
Now we will write a small program that will help the Arduino to “understand” when someone entered the room. https://pastebin.com/1Qe2EVvh
AutoHotkey is a program that performs certain actions on a computer. We’ll write a script that closes the windows when the Arduino detects motion.
Installing AutoHotkey:- Download and install AutoHotkey from the official site
Creating a script: – Open a text editor (for example, Notepad) and create a new file with the extension .ahk.
Paste the following code into the file: – https://pastebin.com/p5x1tYf9 (When a signal is detected, the program will press the WIN + D combination (you can replace it with the one you want, I recommend win + L to lock the device)
Run the script: – Save the file and double click on it to run the script.
Connect the Arduino to the computer using a USB cable.
Download the program to the Arduino via the Arduino IDE.
Run the created AutoHotkey script.
Now, when someone enters the room, the computer will automatically close the active windows.
In this article, we have created an Arduino-based device that detects movement in a room using a PIR sensor and sends a signal to a computer to automatically close windows. This approach can be used to protect sensitive information when you don’t want anyone to see what’s open on your screen. This project can be extended with additional functions, such as turning on an alarm or recording the time of motion detection.
Disclaimer. This article is created for informational purposes only. All advice and instructions are provided for educational purposes and we are not responsible for any possible consequences related to the implementation of this project. Always use safety precautions when working with electronic components.