Connection
The connection of the components to our expansion board can be found in the diagram. It is important to connect all components to voltage, from pins 3V3 and GND. You can supply power to each component separately, or supply it to only one and branch it out (but you need to make your own wires for this). To connect the lasers, you need to use 30 cm dupont wires, or connect shorter cables. Next, we need to read digital information from the photoresistors. Therefore, we will connect their output to pins P0, P1, P8, P9 of the expansion board.
Program
Deep Purple
Now let's describe our sample program. At the beginning, we need to set the pins on which we read information from the sensors to high. Then we just need to constantly check whether the signal from the sensor is interrupted and tell the micro:bit what tone to play. In our case, the tones from the famous song “Deep Purple: Smoke on the Water” are used. If no sensor is interrupted, the program stops all sounds.





