Purpose
To build a desk lamp.
Materials
Background Knowledge
Bricks build-up
Software
Code
Step 1
Click “Advanced” in the MakeCode drawer to see more choices.
In order to programme for the Ring:bit Bricks Pack, we need to add an extension. Click “Extensions” at the bottom of the drawer. Search “Ringbit” in the dialogue box to download it.
Note: If you met a tip indicating codebase will be deleted due to incompatibility, you may continue as the tips tell or build a new project.
Step 2
Drag the set strip to NeoPixel at pin with led as
to on start
, set the pin at P0 port. Initialize the strip in 10 LEDs and in RGB(GRB format).
Step 3
Judge the returned value from “light level” in “forever” block, if the value is less than 10, set the strip color in white; if the value is over 15, set the strip color in black.
Code
Link: https://makecode.microbit.org/_3972aULrT1Dz
You can also download it directly below:
Result
It lights on automatically while the surrounding light is low and lights off when the returned value is higher than your set point.