5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



ARDUBLOCK Project 9: Sound-controlled Light

Posted by Fiona Su on

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.
Materials Required:

  • 1. KEYESTUDIO UNO Control Board *1
  • 2. V5 Sensor Shield*1
  • 3. Piranha LED*1
  • 4. Sound Module*1
  • 5. Female to Female Dupont Line*6

Connection Diagram:

thumb

thumb

After wiring, we can start programming.

thumb

Click “download to Arduino” to see the codes in IDE interface:
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();
}
*******************************************************************************

Result:
After downloading program, have a look at values on serial monitor.

thumb

All Projects

Buy it >> ARDUBLOCK Graphical Programming Starter Kit for Arduino

0 comments

Leave a comment

Please note, comments must be approved before they are published