Night Light
Setup the Microbit
- Launch Browser: Open Chrome
- Open Editor: Navigate to makecode.microbit.org and click the home button
- Optional: Log in if you have a google or Apple Account
- Create: a new project named "Night_Light".
- Hardware Pairing: (If not already paired)
- Connect the micro:bit to the Mac via USB.
- Click the ... button next to Download, select Connect device, and pair the browser directly to the micro:bit hardware.
Night Light - Create an automated nightlight that reacts to the environment.
- Step 1: Delete the default "on start" block. You will use the forever block
- Step 2: Go to Logic and drag an if then else block inside the loop.
- Step 3: From Logic, drag a comparison block (0 < 0) into the true slot of the if statement.
- Step 4: Go to Input, drag the light level sensor block, and place it into the left side of the comparison. Ensure that the operator is less than (<).
- Step 5: Set the right side value to 50 (simulating a dark room).
- Step 6: Inside the then section, add a Basic show icon block to turn the LEDs on.
- Step 7: Inside the else section, add a Basic clear screen block to turn the LEDs off when light is detected.
- Test: Use the cursor to drag the light level slider up and down on the virtual simulator.
-
Test on the Microbit
- Click the Download button.
- Test the program on the microbit (Note: The LED area is also a light sensor)
Microbit for RPSEC Main Page