You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attemting to use this library for driving NeoPixel LEDs. I notice that the .c file has a uBitPinMap, that maps to 3, 2 and 1. However I am unable to get this to work.
This is the code I am attempting to use. Ideally, I would like to use P12 on the micro:bit to drive the NeoPixels. Or even better, to be able to select an available pin in the code.
I changed the code in the ubit-neopixel.c file to:
void neopixel_init(neopixel_strip_t *strip, uint8_t pin_num, uint16_t num_leds)
{
// int uBitPinMap [3] = {3,2,1}; // micro:bit pin numbers are named differently to the hardware numbers
strip->leds = (color_t*) malloc(sizeof(color_t) * num_leds);
strip->pin_num = pin_num;//[pin_num];
strip->num_leds = num_leds;
nrf_gpio_cfg_output(pin_num);
NRF_GPIO->OUTCLR = (1UL << pin_num);
for (int i = 0; i < num_leds; i++)
{
strip->leds[i].simple.g = 0;
strip->leds[i].simple.r = 0;
strip->leds[i].simple.b = 0;
}
}
And then, from the micro:bit code I used:
neopixel_init(&m_strip, MICROBIT_PIN_P1, 64);
This works somewhat, but the display acts strange where the pixels I do specify to light up does , but when I call uBit.sleep(500); the whole screen lights up for half a second.
Hello,
I am attemting to use this library for driving NeoPixel LEDs. I notice that the .c file has a uBitPinMap, that maps to 3, 2 and 1. However I am unable to get this to work.
This is the code I am attempting to use. Ideally, I would like to use P12 on the micro:bit to drive the NeoPixels. Or even better, to be able to select an available pin in the code.
`#include "MicroBit.h"
#include "ubit-neopixel/uBit_neopixel.h"
MicroBit uBit;
MicroBitImage defaultImage(5, 5);
neopixel_strip_t m_strip;
uint8_t dig_pin_num = 2;
void setup() {
neopixel_init(&m_strip, 12, 64);
neopixel_clear(&m_strip);
}
void loop() {
neopixel_set_color(&m_strip, 10, 255,0,0);
neopixel_show(&m_strip);
uBit.sleep(500);
}
int main() {
uBit.init();
setup();
while (1) {
loop();
}
}`
The text was updated successfully, but these errors were encountered: