Turning LEDs on and off with Python
I am one of those “never quite got the hang of electronics” kids. Sure, I built myself a crystal radio. Got that drugstore prescription printer to work with my TRS-80 Model I. And I’ve wired up my share of connectors and cables. But soldering was always a roadblock. And don’t get me started on decrypting the coloured bands on resistors. It’s not that any of this was particularly impenetrable; it’s just that I never took the time, perhaps because sticking to software allowed me to do much more delightful things. But, now I’ve got a Raspberry Pi, and we’re in the Internet of Things era, so the least I can do is get some LEDs turning on and off with Python.
I used this tutorial as the basis for my coding – I just stripped out the IMAP-checking bits; the code looks like this:
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GREEN_LED = 18 RED_LED = 23 GPIO.setup(GREEN_LED, GPIO.OUT) GPIO.setup(RED_LED, GPIO.OUT) GPIO.output(GREEN_LED, True) GPIO.output(RED_LED, True)
Can a “are we getting more than 100% of our electricity from the wind” alert system be too far behind?