Project 9 Sound-controlled Light
1.Introduction
Sound sensor is used to detect the intensity of ambient sound; the intensity is proportional to output voltage.
In this project, we use graphical programming to read out analog value of sound intensity measuring by sound module, ranging from 0 to 1023. And then map the value to 0-255, displaying on serial monitor. Finally set the mapped value as PwM value to control brightness of LED.
2.Materials Required
KEYESTUDIO UNO Control Board *1
V5 Sensor Shield*1
Piranha LED*1
Sound Module*1
Female to Female Dupont Line*6
3.Connection Diagram


4.Sample Code
int _ABVAR_1_sound_value = 0 ;
void setup()
{
pinMode( 11 , OUTPUT);
Serial.begin(9600);
}
void loop()
{
_ABVAR_1_sound_value = 0 ;
_ABVAR_1_sound_value = ( _ABVAR_1_sound_value + analogRead(0) ) ;
analogWrite(11 , map ( _ABVAR_1_sound_value , 0 , 1023 , 0 , 255 ) );
Serial.print("sound val:");
Serial.print(_ABVAR_1_sound_value);
Serial.println();
}
5.Result
After downloading program, have a look at values on serial monitor.
