Skip to main content

Posts

Showing posts with the label music

Microbit + Micro:pixel reacting to music

This post discusses a simple way to get the Micropixel-Micro:Bit combination to change the Neopixels based on the music. Using the accelerometer on the Micro:Bit to provide x,y,z values to provide colour values for the neopixels; the micropixel sits over the speaker and vibrations are picked up.  Simple but it roughly works (see the video at the end of the post). Code from microbit import * import neopixel, random # Setup the Neopixel strip on pin0 with a length of 2 pixels np = neopixel.NeoPixel(pin0, 32) while True:     pxl=11     rd=int(abs(accelerometer.get_x())/20)     gr=int(abs(accelerometer.get_y())/20)     bl=int(abs(accelerometer.get_z())/20)     t1=10     np[pxl] = (0, 0, bl)     np[pxl-1] = (rd, gr, 0)     np[pxl+1] = (0, gr, rd)     np[pxl-2] = (rd, 0, 0)     np[pxl+2] = (0, gr,0)     np.show()     sleep(t1)     np...