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
RED_LED = 23
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?


CJW's picture
CJW on January 9, 2013 - 16:29 Permalink

I put up a raspbian repository if you are using that distro. It might be faster than the default. Use: archive.route2.pe.ca/raspbian/ in /etc/apt.sources (/ubuntu/ is on there too). Updated four times a day!