The examples below explore the possibilities with micro:bit programming, responding to data, and neopixel displays within a lantern.
Each example includes:
|
Rotate and Shift Lights
Set up neopixels with RGB format and individually address each light. Shift or rotate the lights using the A and B buttons. Drawers for blocks used: Input, Variables, Neopixel (a package you must add under settings) New: Setting up neopixel strip, Lighting individual neopixels with specific RGB colors (not a preset color), Using button presses as input, Use preset shift and rotate |
|
|
Rotate speed change with button press
Set up neopixels in a running pattern (or chase). Switch between running fast and running slow with pressing buttons A and B. Drawers for blocks used: Input, Variables, Neopixel New: Setting, storing and changing a variable, Set a whole strand of neopixels to a single preset color, Timing control |
|
|
Temperature changes brightness of lights
Receive air temperature data from a separate micro:bit (look at Sending Code) and set the brightness of the neopixels based on the temperature. Drawers for blocks used: Radio, Logic, Variables, Neopixel, Text New: Set neopixel brightness, receive data from a microbit, use the radio, If-then conditional statements (logic), text blocks Sending Code For the first code to work, a second micro:bit must be sending temperature data out, in this case with a weather:bit, on the same frequency (group) as is being listened to. This is the code that was on the second micro:bit. Drawers for blocks used: Radio, Weather:bit New: Send data on the radio using a name (identifying string) and value (number paired with that string) known as a key-value pair |
|
Substrands of lights respond to two different data
Treat a strand of neopixels as two substrands that can do different things, in this case each responds to a different kind of data. Drawers for blocks used: Radio, Logic, Variables, Neopixel, Text New: Setting sections of a neopixel strand to have different behavior Sending Code This is the code on a second micro:bit connected to a weather:bit that broadcasts garden data (can see in the video). Drawers for blocks used: Weather:bit New: Sending data from the weather:bit, Printing to the LED screen |
|
Pulse lights
Set a strand of neopixels to pulse with a color and turn on or off with button presses. Drawers for blocks used: Input, Logic, Loops, Variables, Math, Neopixel New: Using an indexed loop, using math blocks to calculate a new value |
|
|
Twinkle lights
Set a strand of neopixels to twinkle randomly with a color using buttons to turn on or off. Drawers for blocks used: Input, Logic, Loops, Variables, Math, Neopixel New: Generating and using a random true or false |
|
|
Comparing two light values and changing the color
Compare the light level from the lantern's micro:bit to the light level received from another micro:bit. When light level from the other micro:bit is received the lights change colors based on the comparison. Drawers for blocks used: Input, Radio, Logic, Variables, Neopixel, Text New: Using data from own micro:bit compared to data from someone else's micro:bit Sending code Broadcast (send) light data over radio group 10. Drawers for blocks used: Radio |
|
Live bar graph
Update part of the strand of neopixels to light up based on the value of incoming light data, kind of like a live, changing bar graph. Drawers for blocks used: Radio, Variables, Neopixel, Logic, Text, Math New: Make a new substrand each time data is received |
|