Approved content
The content below is provided by a partner.
This is a rework of the Microsoft Neopixel Extension. It provides a driver for various NeoPixel LED strips and matrices, e.g. https://www.adafruit.com/category/168.
It provides mostly the same interface but
Unfortunately many translations got lost during this rework. Help to reinstate the translations or fix mistakes (my native language is german…) is very welcome!
NeoPixels consist of programmable RGB LEDs (WS2812B), every one of them controlled separately.
// Create a NeoPixel driver - specify the pin, number of NeoPixels, and the type of
// the NeoPixel strip, either standard RGB (with GRB or RGB format) or RGB+White.
let strip = neopixelExtended.create(DigitalPin.P0, 24, neopixelExtended.Format.RGB)
// set pixel colors
strip.setPixelColor(0, 0xffffff) // white
strip.setPixelColor(1, 0xff0000) // red
strip.setPixelColor(2, 0x00ff00) // green
strip.setPixelColor(3, 0x0000ff) // blue
// send the data to the strip
strip.show()
Use ||shift|| or ||rotate|| to move the lights around.
Always use ||show|| to make your changes visible.
This little programm flashes “o” and “k” on a NeoPixel strip arranged as a 5x5 matrix.
// Create a NeoPixel driver - specify the pin, number of LEDs, and the type of
// the NeoPixel strip, either standard RGB (with GRB or RGB format) or RGB+White.
// For a 5x5 matrix you will need to set it to 25 NeoPixel
let strip = neopixelExtended.create(DigitalPin.P0, 25, neopixelExtended.Format.RGB);
// set loop to set the pixel colors
basic.forever(function () {
// set colors for "o"
strip.setMatrix25(
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xFFD700, 0xFFD700, 0xFFD700),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xff0000, 0xff0000, 0xFFD700),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xff0000, 0xff0000, 0xFFD700),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xff0000, 0xff0000, 0xFFD700),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xFFD700, 0xFFD700, 0xFFD700)
)
// send data to the NeoPixel strip
strip.show()
// wait for one second
basic.pause(1000)
// set colors for "k"
strip.setMatrix25(
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xff0000, 0xff0000, 0xFFD700),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xff0000, 0xFFD700, 0xff0000),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xFFD700, 0xff0000, 0xff0000),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xff0000, 0xFFD700, 0xff0000),
neopixelExtended.rowOf5(0xff0000, 0xFFD700, 0xff0000, 0xff0000, 0xFFD700)
)
// send data to the NeoPixel strip
strip.show()
// wait for one second
basic.pause(1000)
})
Use ||setWiringDirection|| to adjust for different wiring of the NeoPixel matrix.
Use ||setMatrixColor|| to set single pixels in the matrix.
MIT
neopixel-extended=github:PasAlt/pxt-neopixel-matrix-extension#v2.1.2