Connect the knob module to the interface P1 of expansion board; Connect the rainbow LED strip to the interface P2 of expansion board.
Functions: Realize the music performance with the LED strip when adjusting the rotation angle of the knob.
When the knob is turned by hand, the value of the P1 pin changes from 0 to 1023 and is divided into 8 small ranges, corresponding to one octave "Do ~ Do’" in the music and the number of changing LEDs of the the light strip.
The input value of P1
The LED strip
Light one LED
Light two LEDs
Light three LEDs
Light four LEDs
Light five LEDs
Light six LEDs
Lights seven LEDs
Light seven LEDs in red
STEP1: the logic diagram to realize DJ bandstand.
STEP2: the editing of logic statement "if", the operations go as follows
STEP3: judge the range of the input value of the knob(P1) and make the value correspond to the LED strip and sound. The following is the control procedures in the first area.
STEP4: Since there are only 7 LEDs, so "Do’" can be expressed in a different way in the 8th zone.
STEP5：the final program
Exercises for improvement
Utilize the 5×5 LED matrix of the micro:bit. When different syllables are played, each of them should be correspondingly displayed by LEDs. Just have a try.