Корак 1: Уради
Шта је ово?
A nightlight that lights up your BBC micro:bit’s LED display in the dark.
Увод
Водич за програмирање
This project uses the micro:bit’s LEDs as a light sensor input to make a light that switches on automatically when it gets dark.
The micro:bit’s light sensor measures light in a range from 0 (very dark) to 255 (very bright).
Како то ради
- An infinite loop in the code keeps the micro:bit checking light levels.
- It uses logic to decide whether to turn the LEDs on or off. A conditional instruction (if… then… else) makes the decision to turn the LED lights on or off.
- If the light level falls below 100, then it lights up the LEDs on the micro:bit’s display. Else (otherwise), it clears the screen to turn the LED lights off.
- Test it out by covering the display or shining a light on it, and see if the LEDs light up when it’s dark.
- You may need to change the 100 number depending on the light levels around you. Larger numbers will make the light come on more easily. Smaller numbers will make the light only come on when it’s very dark.
Шта вам је потребно
- micro:bit (или симулатор у MakeCode)
- MakeCode или Python уређивач
- батерије (опционално)
- извор светлости и нешто чиме се покрива micro:bit уређај
Корак 2: Програмирај
Корак 3: Унапреди
- Промените слику тако да приказује месец или звезду када падне мрак.
- Причврстите micro:bit за вашу торбу или одећу како бисте га користили као додатну сигурност током ходања или вожње бицикла - да ли можете да направите да трепери како би се више истицао?
- Испробајте овај MakeCode пројекат који чини да лед екран постаје светлији и тамнији у зависности од количине светлости која пада на micro:bit. Где сте још видели ствари које на овај начин реагују на светлост?
This content is published under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.