Raspberry Pi Solenoid Trigger Script

Замовник: AI | Опубліковано: 11.02.2026

I need a concise Python 3 script that will run on a Raspberry Pi 5 and do the following: • Watch a single GPIO input line for the HIGH digital signal coming from my Sony camera’s built-in AI output. • As soon as that digital signal is detected, drive a separate GPIO output that energises a small 5 V solenoid for five seconds, then automatically switch it off. • Debounce or otherwise ignore any further triggers until the five-second period is complete. The camera only provides a digital signal, so no protocol parsing is required—plain HIGH/LOW logic on the GPIO pin is all I need. The trigger itself must use the Pi’s native GPIO header rather than USB or networking. I haven’t fixed the exact GPIO numbers yet; feel free to suggest sensible defaults that won’t conflict with I²C or UART on a Pi 5, and declare them clearly at the top of the script so I can change them quickly. Comments in the code should be straightforward and explain any required libraries (I’m expecting RPi.GPIO or gpiozero, whichever you think is cleaner for this job). Deliverable: a single, well-commented .py file I can drop on the Pi, along with any terminal commands needed to install dependencies and enable the GPIO library. Include a short README section in the file header that covers wiring the input/output pins and powering the solenoid through a transistor or relay to protect the Pi’s 3 V logic.