Light up neopixel strip
Light up a neopixel led strip with just 4 lines of code!
YOU WILL NEED
- 1 x BBC Micro:bit
- 1 x Neopixel LED strip
- 1 x sensor:bit (or any breakout board)
Connect the components
(a) Slot a BBC micro:bit to the sensor:bit
(b) Plug in a neopixel light strip to PIN1
- 1 x BBC micro:bit
- 1 x sensor:bit
- 1 x neopixel LED strip
To connect a neopixel LED strip, we need to import a special package in MakeCode.
(a) Click on the ‘Advanced’ drawer, select 'Extensions'.
(b) Search for ‘neopixel’ and click on it to import.
(c) You’ll need to re-import the extension again for new projects in the future.
Initialise LED strip
Before coding for the LED strip, we need to initialise it.
(a) In the Neopixel drawer, drag a 'set strop to...' block into on start
(b) Change the pin number
(c) Change the number of pixels
(a) Right after the LED strip initialisation block, drag a show rainbow block
(b) To make the colors rotate, in a forever block, drag a 'strip rotate pixel' and a 'strip show' block.
You’ve completed your very own 'light show'. Don’t forget to plug a micro USB cable from your laptop to the top of your micro:bit, and click ‘Download’ to download the code to your micro:bit.
Made this activity? Good Job! Now spread the word. Share a photo of your creation on social media with #letsgethacking #Lightupneopixelstrip