Programming The BBC Micro:Bit For NeoPixels | Tutorial Accompanying Video
HTML-код
- Опубликовано: 15 июл 2024
- In this video I teach you how to create two different animations using NeoPixel RGB LEDs and the BBC Micro:bit. I utilize both push buttons as well as the accelerometer built into the Micro:bit.
If you would like to see the full project tutorial, please head over to Element14.com at the link below. Наука
Yes, if you have time please make more microbit tutorial, if can use MQTT with esp8266 + microbit, it will be good, there are some using low powered bluetooth with microbit and pi, but not common.
Nice project please do some more animations
Great Tutorial by please show us it working!
AT the "set micro pixel color at" line I thought it was a change sign bug but multiply "**" makes it work to. The source code for that block is probably on GitHub .......
Below is the code used in the above tutorial. It is in Java script you can see it in blocks if you want, just switch to blocks. Before cut and pasting it in load "neopixel extension" I made a change at "set pixel color at " and got good results.
let z = 0
let y = 0
let x = 0
let strip = neopixel.create(DigitalPin.P0, 24, NeoPixelMode.RGB)
let mode = true
input.setAccelerometerRange(AcceleratorRange.EightG)
strip.clear()
strip.setBrightness(255)
while (true) {
if (input.buttonIsPressed(Button.A)) {
mode = true
basic.showLeds(`
. . # . .
. # # . .
. . # . .
. . # . .
. # # # .
`)
} else {
if (input.buttonIsPressed(Button.B)) {
mode = false
basic.showLeds(`
. # # # .
. . . # .
. # # # .
. # . . .
. # # # .
`)
}
if (mode == true) {
strip.showRainbow(1, 360)
} else {
if (mode == false) {
x = input.acceleration(Dimension.Y) - 55
y = input.acceleration(Dimension.X) * 2
z = input.acceleration(Dimension.Z) * 2
strip.setPixelColor(0, neopixel.rgb(x, y, z))
strip.shift(1)
strip.show()
basic.pause(50)
}
}
}
}
The download can not be edited in the new makecode Block editor which is a pity. This may be an issue with the new editor or with the code?
I believe the new editor is the issue.