From: jimmy Date: Fri, 28 Jun 2024 01:17:07 +0000 (-0500) Subject: twinkling purple/pink lights X-Git-Url: https://vault307.fbx.one/gitweb/LEDstrand.git/commitdiff_plain/HEAD?ds=sidebyside twinkling purple/pink lights --- 98d2a18c615dc7c252da605b463c1cd9bfb7d024 diff --git a/main.py b/main.py new file mode 100644 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 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 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 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() +