Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
ELECFREAKS
Published

How to Make a Simple Little Lamp

In life, sometimes there will be no electricity. At this time, if there is a small electric light, it will be much more convenient. Today, I

BeginnerFull instructions provided30 minutes64
How to Make a Simple Little Lamp

Things used in this project

Hardware components

BBC micro:bit V2
×1
Sensor:bit expansion board
×1
ring of lights
×1
Battery box
Male to female Dupont line x 1 AAA Battery x 2
×1

Software apps and online services

KidsIoT
Hardware Source

Story

Read more

Schematics

Connection step diagram

Code

program

JavaScript
https://makecode.microbit.org/_2WXFFsfyuLwH
input.onButtonPressed(Button.A, function () {
    K = 1
})
input.onButtonPressed(Button.AB, function () {
    K = 0
})
input.onButtonPressed(Button.B, function () {
    K = 2
})
let K = 0
K = 0
let strip = neopixel.create(DigitalPin.P2, 8, NeoPixelMode.RGB)
basic.forever(function () {
    if (K == 1) {
        strip.showColor(neopixel.colors(NeoPixelColors.White))
    } else if (K == 2) {
        strip.showColor(neopixel.colors(NeoPixelColors.Blue))
    } else if (K == 0) {
        strip.showColor(neopixel.colors(NeoPixelColors.Black))
    }
})

Credits

ELECFREAKS
11 projects • 0 followers
ELECFREAKS focuses on the micro:bit developed kits and accessories. We are one of the official partners of the BBC micro:bit Foundation.
Contact

Comments

Please log in or sign up to comment.