0

My students are building kind of game using the Micro:bit and Grove kit extension. Their setup is a ledstrip, 4 digit display and an ultra sonic sensor. They are using the code blocks from the makecode editor. They want the display to show the distance of the ultrasonic sensor, but it only shows it (and updates) when the ledstrip is green and it stops when the ledstrip is red.

def on_button_pressed_a():
    control.reset()
input.on_button_pressed(Button.A, on_button_pressed_a)

Display = grove.create_display(DigitalPin.P1, DigitalPin.P15)
Rainbow = neopixel.create(DigitalPin.P2, 30, NeoPixelMode.RGB)
nummer = 0

def on_forever():
    Display.show(grove.measure_in_centimeters(DigitalPin.P0))
    basic.pause(100)
basic.forever(on_forever)

def on_forever2():
    global nummer
    if nummer == 0:
        Rainbow.show_color(neopixel.colors(NeoPixelColors.BLUE))
        nummer = 1
        basic.pause(randint(1000, 2000))
    else:
        Rainbow.show_color(neopixel.colors(NeoPixelColors.GREEN))
        nummer = 0
        basic.pause(randint(5000, 10000))
basic.forever(on_forever2)

We switched the colors, but the problem remains when using red. When we use green and green, there is no problem and when we use green blue also no problem. Orange and green gives the same problem. Does anyone know why this is?

Roderik
  • 3
  • 2
  • It may be that too much power is needed for full on red (on top of the display and ultrasonics). Try reducing the brightness to, say, 10%, or reducing the number of neopixels initialised from 30 to,say, 10. – meuh Feb 03 '23 at 14:23

0 Answers0