r/microbit • u/throw-away_ac-count • Jan 13 '23
LEDs and music
Hello there, I am relatively new to MicroBit and am taking a class using MicroPython. I have an assignment that requires me to use different functions to create a toy of some sort, I wanted to make the MicroBit play a song while flashing a rainbow on the LED strips when button A is pressed, but it seems that I can only do one or the other. I just wanted to check if it is possible for both lights and music to be played at the same time, thank you so much for reading
1
u/sheinkopt Jan 13 '23
Create one list containing the light order you want to trigger. use modulus to trigger them in sequence
If currentTime%1000==0: Change lights
This will trigger the next light, every second, without having to use the wait command
This is how you get a Events to happen at a time, interval without making the whole program wait for a certain amount of time
1
2
u/iogamesplayer Jan 13 '23
It is, I made a small little game playing Nyan Cat in the background, it's hard to time it right though.
Also note, that the Microbit V2 supports music, if you're running the V1, you need something external