Devices & Components
Arduino Uno Rev3
Breadboard 100x160
Basic Red 5mm LED
KY-037
Jumper wire
Hardware & Tools
Screw drivers (various)
Software & Tools
Arduino IDE
Project description
Code
Code
cpp
Upload this Code to Arduino Board
1const int soundSensorPin = A0; // Analog pin connected to the sound sensor 2const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; // Digital pins connected to the LEDs 3 4void setup() { 5 pinMode(soundSensorPin, INPUT); 6 for (int i = 0; i < 10; i++) { 7 pinMode(ledPins[i], OUTPUT); // Set the LED pins as outputs 8 } 9 Serial.begin(9600); // Initialize serial communication for debugging 10} 11 12void loop() { 13 int soundValue = analogRead(soundSensorPin); // Read the analog input value 14 15 for (int i = 0; i < 10; i++) { 16 int lowerBound = 70 + (i * 100); 17 int upperBound = lowerBound + 100; 18 19 if (soundValue >= lowerBound && soundValue < upperBound) { 20 for (int j = 0; j <= i; j++) { 21 digitalWrite(ledPins[j], HIGH); // Turn on the LEDs up to the current index 22 } 23 for (int k = i + 1; k < 10; k++) { 24 digitalWrite(ledPins[k], LOW); // Turn off the remaining LEDs 25 } 26 } 27 } 28 29}
Downloadable files
Circuit Diagram
This will help you to Connect all wires
Circuit.png

Code
Code
Code.ino
Comments
Only logged in users can leave comments