Skip to content

Commit a27a8f6

Browse files
committed
New script to simulate fireplace lights
1 parent 6ea5e3d commit a27a8f6

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

fireplace-lights.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#-----------------------------------------------------------------------------#
2+
# Fireplace Lights
3+
#
4+
# Micropython code for Raspberry Pi Pico w
5+
#
6+
# File : fireplace-lights.py
7+
# Source : https://github.com/RPiSpy/pi-pico
8+
#
9+
# Desc : Simulate a fire place with two neopixels
10+
# Hardware : Pi Pico or Pi Pico W
11+
# 2 WS2812 NeoPixels
12+
# Software : Requires neopixel.py
13+
#
14+
# Author : Matt Hawkins
15+
# Website : https://www.raspberrypi-spy.co.uk/
16+
#
17+
# In memory of Diana Keating who taught me to make stuff
18+
# as soon as I could hold a pen.
19+
#
20+
#-----------------------------------------------------------------------------#
21+
22+
import time
23+
import random
24+
from neopixel import Neopixel
25+
26+
# NeoPixel settings
27+
NEOPIXEL_GPIO = 26
28+
NEOPIXEL_COUNT = 2
29+
30+
BRIGHTNESS_MAX = 200
31+
BRIGHTNESS_MIN = 10
32+
33+
# Amound of Red, Green and Blue to use
34+
COLOUR_RED = 255
35+
COLOUR_GREEN = 80
36+
COLOUR_BLUE = 0
37+
38+
pixels = Neopixel(NEOPIXEL_COUNT, 0, NEOPIXEL_GPIO, "GRB")
39+
40+
while True:
41+
42+
# For each pixel ...
43+
for pixel in range(0,NEOPIXEL_COUNT):
44+
45+
# Set random brightness between Min and Max values
46+
brightness_p = random.randint(BRIGHTNESS_MIN,BRIGHTNESS_MAX)
47+
48+
# Set starting colours of neopixels
49+
# Max red, zero blue and enough random green to give yellows and oranges
50+
colour_p = (COLOUR_RED,random.randint(0,COLOUR_GREEN),COLOUR_BLUE)
51+
52+
# Set pixel colour and brightness
53+
pixels.set_pixel(pixel, colour_p, brightness_p)
54+
pixels.show()
55+
56+
# Wait random time between 50-80 milliseconds
57+
# to give a flicker effect
58+
time.sleep_ms(random.randint(50,80))

police-lights.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# NeoPixel settings
2222
NEOPIXEL_GPIO = 26
2323
NEOPIXEL_BRIGHTNESS_LOW = 1
24-
NEOPIXEL_BRIGHTNESS_HIGH = 50
24+
NEOPIXEL_BRIGHTNESS_HIGH = 100
2525

2626
COLOUR_BLUE = (0,0,255)
2727
COLOUR_RED = (255, 0, 0)

0 commit comments

Comments
 (0)