The sound sensor has 4 pins. 2 of which we should be familiar with, the + pin which is short for power or 3.3V pin, which takes in our power. The GND pin, which leads to the ground pin on our GPIO board. There are two other pins. AO and DO?
The DO pin is short for Digital Output. What that means is that the signal sent out of this pin is either going to be a 1 or a 0, just like binary, it’s either on (It can sense enough sound), or off (It isn’t receiving enough sound.
The AO pin is short for Analog Output. What this generally means is that the signal coming out of it has a range from 0 to 1023, 1023 being equivalent to full power (512 being ½ power etc). However our sound sensor is a bit funny. It only has numbers between 0 to 32, with 32 being full volume.
After building this circuit. We want to create code such that:
We have a new block here, called plot bar graph of ( ) up to ( ), this lights up our LED’s more or less, depending on our input. Our input is the P1 pin, which we can put into our code as “analog read pin [P1]” found in Advanced -> Pins. We reduce this number by 24 using the Math -> "-" (Minus) block, to reduce the effect of background noise. And we have a range up to 8.
If you wish to have greater precision, for every number you reduce from the minus block, add 1 to the "up to" number. Eg P1 - 20 up to 12 etc.