User Manual
Software Code
Open Arduino IDE.
Copy the following code, click Verify to check for syntax errors. Verify that there are no
errors, and you can upload the code.
//Sound Control Light 
int soundPin = A2; // Analog sound sensor is to be attached to analog 
int ledPin = 4; // Digital LED is to be attached to digital 
void setup() { 
 pinMode(ledPin, OUTPUT); 
 Serial.begin(9600); 
} 
void loop(){ 
 int soundState = analogRead(soundPin); // Read sound sensor’s value 
 Serial.println(soundState); 
 // if the sound sensor’s value is greater than 200, the light will be o
n for 5 seconds. 
 //Otherwise, the light will be turned off 
 if (soundState > 200) { 
 digitalWrite(ledPin, HIGH); 
 delay(100); 
 }else{ 
 digitalWrite(ledPin, LOW); 
 } 
} 
You can also see the light intensity readings from the Serial Monitor, navigate to Tools -> Serial
Plotter.
38
Grove Beginner Kit For Arduino®










