Hi all, I am trying to use a scroll;bit to display different messages depending on which button has been pressed. I want each message to be scrolled multiple times (ideally as a continuous loop). My base code in java to display each message twice is:
input.onButtonPressed(Button.A, function () {
for (let i = 0; i < 2; i++) {
scrollbit.scrollText(“one”, 128, 50)
}
})
input.onButtonPressed(Button.B, function () {
for (let i = 0; i < 2; i++) {
scrollbit.scrollText(“two”, 128, 50)
}
})
The " for (let) " line controls the number of time the message is scolled.
If I change it to " while (true) " when I restart the micro:bit and press one of the buttons I get continuous scrolling but pressing the other button doesn’t change the message I have to reset first!
input.onButtonPressed(Button.A, function () {
while (true) {
scrollbit.scrollText(“one”, 128, 50)
}
})
input.onButtonPressed(Button.B, function () {
while (true) {
scrollbit.scrollText(“two”, 128, 50)
}
})
Its like once the first button has been pressed the micro:bit stops ‘listening’ for any other inputs (i.e. the other button being pressed).
Any help gratefully recieved!
Andrew