PROJECTS micro:bit micro:bit Project 10: DJ PANEL
DFRobot
Oct 16 2018 260343
Components needed
Hardware Connection
Connect the knob module to the interface P1 of expansion board;
Connect the rainbow LED strip to the interface P2 of expansion board.
Program
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 | Sound | The LED strip |
0-128 | Do | Light one LED |
128-256 | Re | Light two LEDs |
256-384 | Me | Light three LEDs |
384-512 | Fa | Light four LEDs |
512-640 | So | Light five LEDs |
640-768 | La | Light six LEDs |
768-996 | Ti | Lights seven LEDs |
996-1023 | Do’ | 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.