What if instead of the first LED just turning on and off we want to slowly make the LED get brighter and then slowly dimmer? To do this we will change the brightness of the red from off (0) to fully on (255) in steps
with a small delay of 1/100th of a second between the steps.
1 2 3 4 5 6 7 8 910111213141516171819202122
fromneopixelimportNeoPixelfromtimeimportsleepNUMBER_PIXELS=1LED_PIN=0strip=NeoPixel(machine.Pin(LED_PIN),NUMBER_PIXELS)# the time between each of the 255 brightness stepsdelay=.01whileTrue:# slowly get brighterforiinrange(0,255):strip[0]=(i,0,0)# red=255, green and blue are 0strip.write()# send the data from RAM down the wiresleep(delay)# slowly get dimmerforiinrange(255,0,-1):strip[0]=(i,0,0)strip.write()sleep(delay)