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 ))
0 commit comments