0
For a Raspberry Pi ? OK, I'll assume you connect with GPIO pins on the Pi
You need to learn a bit how to use GPIO pins if you don't already, and then learn how to use the RPi.GPIO library (pre-installed with the latest versions of Raspbian). Then it is as simple as knowing what event you want to react to and coding that. It's actually simpler to code than to know what to implement.
Hope it will help.
0
I'd think you'd just keep the pin on