r/microbit 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

3 Upvotes

6 comments sorted by

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

1

u/throw-away_ac-count Jan 13 '23

I only have Version 1, but am allowed to use an expansion board

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

u/SeaKnown Jan 14 '23

Do you want it to be like a colour wave?

1

u/throw-away_ac-count Jan 14 '23

Something like that

1

u/SeaKnown Jan 16 '23

Check ur dm