The Pi Candle

I spent a bit of last weekend experimenting with the Raspberry Pi, and I came up with a fake candle! I used the cap of an old Christmas light, a yellow LED, some small dowels drilled with holes, and a lot of superglue. Then I programmed it in Python using the software PWM so it flickers realistically. I didn’t use any solder, I just kind of twisted the wires together. I also made an Arduino version as well.

pi candle building the pi candle

#The Pi Candle Code

#Amanda Cole 2015

import RPi.GPIO as GPIO, time, random
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(26, GPIO.OUT) #26 is the LED

flame = GPIO.PWM(26,60)
flame.start(0)

try:
____while True:
________flame.ChangeDutyCycle(random.randint(0,100))
________time.sleep((random.random())/6)

except KeyboardInterrupt:
____GPIO.cleanup()

Advertisements

2 thoughts on “The Pi Candle

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s