]> vault307.fbx.one Git - LEDstrand.git/commitdiff
twinkling purple/pink lights master
authorjimmy <jimipunk88@gmail.com>
Fri, 28 Jun 2024 01:17:07 +0000 (20:17 -0500)
committerjimmy <jimipunk88@gmail.com>
Fri, 28 Jun 2024 01:17:07 +0000 (20:17 -0500)
main.py [new file with mode: 0644]
main0.py [new file with mode: 0644]
main1.py [new file with mode: 0644]
main2.py [new file with mode: 0644]

diff --git a/main.py b/main.py
new file mode 100644 (file)
index 0000000..7f72a1e
--- /dev/null
+++ b/main.py
@@ -0,0 +1,51 @@
+# Imports
+from machine import Pin
+from neopixel import NeoPixel
+import time, random
+
+# LED details
+GPIOnumber = 28
+LEDcount = 15
+
+# set up buttons
+cBtn=Pin(16,Pin.IN,Pin.PULL_UP)
+sBtn=Pin(17,Pin.IN,Pin.PULL_UP)
+
+# Define the strand pin number and number of LEDs from variables
+strand = NeoPixel(Pin(GPIOnumber), LEDcount)
+
+global mycolour
+mycolour=(78,0,45)
+pink=(253,58,73)
+# Turn off all LEDs before program start
+strand.fill((mycolour))
+strand.write()
+time.sleep(1)
+
+def ledStrand():
+    i=random.randint(0,LEDcount-1)
+    strand[i]=(mycolour)
+    strand.write()
+    time.sleep(.09)
+    strand[i]=(pink)
+    strand.write()
+    time.sleep(1.09)
+    
+def nColor():
+    global mycolour
+    mycolour=(random.randint(0,255),random.randint(0,255),random.randint(0,255))
+    time.sleep(0.09)
+    
+def clearStrand():
+    strand.fill((0,0,0))
+    strand.write()
+
+while True:
+    ledStrand()
+    if sBtn.value()==0:
+        clearStrand()
+        break
+    if cBtn.value()==0:
+        nColor()
+
+
diff --git a/main0.py b/main0.py
new file mode 100644 (file)
index 0000000..7f72a1e
--- /dev/null
+++ b/main0.py
@@ -0,0 +1,51 @@
+# Imports
+from machine import Pin
+from neopixel import NeoPixel
+import time, random
+
+# LED details
+GPIOnumber = 28
+LEDcount = 15
+
+# set up buttons
+cBtn=Pin(16,Pin.IN,Pin.PULL_UP)
+sBtn=Pin(17,Pin.IN,Pin.PULL_UP)
+
+# Define the strand pin number and number of LEDs from variables
+strand = NeoPixel(Pin(GPIOnumber), LEDcount)
+
+global mycolour
+mycolour=(78,0,45)
+pink=(253,58,73)
+# Turn off all LEDs before program start
+strand.fill((mycolour))
+strand.write()
+time.sleep(1)
+
+def ledStrand():
+    i=random.randint(0,LEDcount-1)
+    strand[i]=(mycolour)
+    strand.write()
+    time.sleep(.09)
+    strand[i]=(pink)
+    strand.write()
+    time.sleep(1.09)
+    
+def nColor():
+    global mycolour
+    mycolour=(random.randint(0,255),random.randint(0,255),random.randint(0,255))
+    time.sleep(0.09)
+    
+def clearStrand():
+    strand.fill((0,0,0))
+    strand.write()
+
+while True:
+    ledStrand()
+    if sBtn.value()==0:
+        clearStrand()
+        break
+    if cBtn.value()==0:
+        nColor()
+
+
diff --git a/main1.py b/main1.py
new file mode 100644 (file)
index 0000000..ec49221
--- /dev/null
+++ b/main1.py
@@ -0,0 +1,48 @@
+# Imports
+from machine import Pin
+from neopixel import NeoPixel
+import time, random
+
+# LED details
+GPIOnumber = 28
+LEDcount = 15
+
+# set up buttons
+cBtn=Pin(16,Pin.IN,Pin.PULL_UP)
+sBtn=Pin(17,Pin.IN,Pin.PULL_UP)
+
+# Define the strand pin number and number of LEDs from variables
+strand = NeoPixel(Pin(GPIOnumber), LEDcount)
+
+global mycolour
+mycolour=(78,0,45)
+# Turn off all LEDs before program start
+strand.fill((mycolour))
+strand.write()
+time.sleep(1)
+
+def ledStrand():
+    i=random.randint(0,LEDcount-1)
+    strand[i]=(0,0,0)
+    strand.write()
+    time.sleep(0.09)
+    strand[i]=(mycolour)
+    strand.write()
+    time.sleep(0.09)
+    
+def nColor():
+    global mycolour
+    mycolour=(random.randint(0,255),random.randint(0,255),random.randint(0,255))
+    time.sleep(0.09)
+    
+def clearStrand():
+    strand.fill((0,0,0))
+    strand.write()
+
+while True:
+    ledStrand()
+    if sBtn.value()==0:
+        clearStrand()
+        break
+    if cBtn.value()==0:
+        nColor()
diff --git a/main2.py b/main2.py
new file mode 100644 (file)
index 0000000..5df92b7
--- /dev/null
+++ b/main2.py
@@ -0,0 +1,50 @@
+# Imports
+from machine import Pin
+from neopixel import NeoPixel
+import time, random
+
+# LED details
+GPIOnumber = 28
+LEDcount = 15
+
+# set up buttons
+cBtn=Pin(16,Pin.IN,Pin.PULL_UP)
+sBtn=Pin(17,Pin.IN,Pin.PULL_UP)
+
+# Define the strand pin number and number of LEDs from variables
+strand = NeoPixel(Pin(GPIOnumber), LEDcount)
+
+global mycolour
+mycolour=(78,0,45)
+pink=(253,58,73)
+# Turn off all LEDs before program start
+strand.fill((mycolour))
+strand.write()
+time.sleep(1)
+
+def ledStrand():
+    i=random.randint(0,LEDcount-1)
+    strand[i]=(mycolour)
+    strand.write()
+    time.sleep(0.09)
+    strand[i]=(pink)
+    strand.write()
+    time.sleep(0.09)
+    
+def nColor():
+    global mycolour
+    mycolour=(random.randint(0,255),random.randint(0,255),random.randint(0,255))
+    time.sleep(0.09)
+    
+def clearStrand():
+    strand.fill((0,0,0))
+    strand.write()
+
+while True:
+    ledStrand()
+    if sBtn.value()==0:
+        clearStrand()
+        break
+    if cBtn.value()==0:
+        nColor()
+