Welcome to our exciting journey into electronics! In this first blog in our series we will take you through an interactive, hands-on experience: turning sound into light using Arduino and a few other components. Imagine switching a light on and off just by clapping or snapping your fingers—that is the magic of electronics we will explore today.
Soon you will discover what you can create with a few simple components and your curiosity as fuel!
First, let’s look at the electronic components we will use.
Components Used in the First Project
| 1x KY-037 sound sensor |
| Arduino UNO |
| 1x breadboard |
| 1x LED |
| 1x 220 Ohm resistor |
| Jumper wires/Dupont cables |
To build the circuit, we use a breadboard, also known as a solderless prototyping board. This clever tool connects components without soldering, making it easy to experiment and quickly change the circuit.
At the centre of the project is Arduino—a versatile microcontroller platform for programming and controlling circuits. It acts as the brain, detecting sound through a sound sensor called KY-037.
To show the effect of sound, we use an LED (Light Emitting Diode). This compact light source responds when Arduino detects sound above a threshold. A resistor protects the LED from excessive current.
To connect the components, use jumper wires. These flexible, colourful wires easily connect Arduino, the sound sensor, LED and resistor.
TIP: Red wires commonly indicate positive supply connections, while black wires indicate ground (GND) and negative connections. Following this convention makes connections easier to identify when working with components and microcontrollers.
Now that the components are introduced, let’s examine how they work. We start with Arduino UNO.
Arduino UNO
Arduino UNO is a small device serving as the heart and brain of countless electronics projects. Designed to be easy to use and program, it suits beginners and experienced enthusiasts alike.
Its pins connect it to other components. The classic UNO has digital I/O and analogue inputs, but no dedicated capacitive-touch pins. Jumper wires connect components and extend its functionality. Touch sensing requires additional circuitry or a suitable library.
The numbers and letters beside the headers identify individual pins. These labels are essential when connecting and controlling components.
Arduino IDE (Integrated Development Environment) is a powerful tool that lets you write and upload Arduino code. In the code, pin numbers identify the connections whose behaviour you configure, allowing control of connected components.
Arduino sketches use the C++ programming language, but do not worry if it is unfamiliar. Arduino IDE offers a friendly interface and useful features to help you program.
Arduino brings creative ideas to life, from blinking lights and motion-controlled devices to robots and advanced sensor projects. Your imagination sets the possibilities!
LED
An LED has two terminals. Let’s look at them.
First is the anode (+), the positive terminal. As a metaphor, think of it as welcoming energy into the LED so it can shine; electrically, conventional current enters the anode during normal forward operation.
On the other side is the cathode (-), the negative terminal. Conventional current leaves the cathode during forward operation. The completed circuit allows the LED to emit light; this is not caused by the Earth’s magnetic attraction.

Physical features help identify the terminals. On a typical untrimmed through-hole LED, the longer lead is the anode, while the shorter lead is the cathode. This is a useful clue, but confirm the package marking or datasheet when uncertain.
So... always remember to connect the anode towards the positive supply and the cathode towards the negative/ground side, with a suitable series resistor or current driver. Never connect a bare LED directly across the supply.
Breadboard
Let’s explore how breadboards work. They let us build circuits without soldering, like a board on which components can quickly be placed and connected.
Breadboards have holes arranged in rows and columns, electrically linked in specific groups. Typical boards have two terminal-strip sections separated by a central gap and power rails along the sides, like the board used here.

Figure 1
A typical breadboard, divided into sections and rows for flexible component connections.
Here the first two horizontal rows are marked A. Blue and red lines show their internal connections.
The two middle sections are B and C. Grey lines show which holes connect.
The final horizontal rows are marked D, with connections shown like those at A.
In the pictured orientation, terminal groups run vertically and power rails horizontally. Orientation does not define connectivity: check the actual board, because rails may be split and opposite sides of the centre gap are separate.
Inserting a jumper, resistor or leaded component such as an LED connects it to the other holes in that group.
Jumper wires join different groups. Place one end in one hole and the other in another group to connect components through the board’s internal links.
Breadboards are flexible: move components, change connections and experiment without soldering. Wiring mistakes can still damage components, so disconnect power before changing the circuit and check connections. They are useful for beginners and experienced enthusiasts alike.
Now we understand breadboards, let’s introduce the KY-037 sound sensor.
Microphone Sensor Configuration
Let’s see how to configure the sensor.
This small, versatile module detects sound and converts it to an electrical signal Arduino can process.

Figure 2
D0: A digital output from the threshold comparator. Its active state can vary with module design; measure whether detected sound produces HIGH or LOW and make the code match.
+: The supply-voltage pin. Connect the rated positive supply, normally 5V in this UNO project, from Arduino or a suitable external source.
GND: Ground. Connect to Arduino GND and any external supply ground to establish a common reference.
A0: The analogue microphone output. A classic UNO ADC can sample it as values from 0 to 1023, but a single reading is not calibrated loudness or sound-pressure level. Waveform sampling and calibration are needed for quantitative sound measurements.
KY-037 has a built-in microphone and an adjustable potentiometer. The microphone produces a small electrical signal from sound. The potentiometer normally adjusts the digital comparator threshold, not a calibrated microphone gain or decibel setting.
When sound crosses a threshold, the electrical signal reaches Arduino, allowing us to trigger actions such as switching the LED. To set the threshold, follow these steps.
First connect the 5V pin on the sensor to Arduino 5V and the ground/GND pin to Arduino GND. The power indicator should light; the comparator indicator depends on the threshold and module. Now use a screwdriver.
Carefully adjust the potentiometer while observing the comparator indicator. Turn it until the indicator just changes state at your desired sound level. Direction and indicator location vary by module. Find the “sweet spot” where a test sound crosses the threshold reliably. Make small adjustments and test with the sound you want to trigger it. I set mine to trigger when I snap my fingers.
This sets a practical trigger threshold for the surroundings, not an exact calibrated sound level. Test again if background noise, distance or microphone orientation changes.
With the threshold set, we can build the circuit and program Arduino to turn sound into light.
Circuit Setup
We use these Arduino connections:
Pin 2 for the sound sensor
Pin 4 for the LED
We also use 5V and Arduino GND.
First connect the sound sensor to Arduino by connecting its GND pin to Arduino GND and its VCC pin to Arduino 5V. Then connect the sensor’s D0 pin to Arduino pin 2. This receives the sensor’s digital output for the program.
To limit LED current, connect one end of the resistor to Arduino pin 4 and the other to the LED anode (longer lead). Connect the LED’s cathode (shorter lead) directly to Arduino GND. The series resistor limits current; choose its value for the supply, LED forward voltage and permitted LED/GPIO current.The circuit is pictured below.

Figure 3
The project circuit.
We have explained D0, +, GND and A0 and their purposes. This project uses D0; A0 is described for reference. Now we can program Arduino.
Next we explore Arduino code. No previous programming experience is needed: we introduce basic concepts and structures and guide you through the sound-sensor program.
Let’s continue to the code!
Arduino Beginner’s Guide
This guide explains the basic structure of Arduino sketches—small programs running on Arduino microcontrollers.
Arduino is an open-source platform for interactive projects combining hardware and software. Popular with hobbyists, students and professionals, it supports projects from blinking LEDs to complex robots.
The microcontroller acts as the brain, receiving sensor inputs, performing calculations and controlling outputs such as LEDs or motors. Its digital and analogue pins connect components that the program controls.
Here the pins receive sound-sensor signals and control the LED. Arduino sketches define conditions and actions based on incoming sound, creating a responsive sound-controlled project.
Download Arduino IDE here and open it so we can explore sketch structure and how to use it.
Arduino IDE Configuration
Your first sketch does not require extensive programming knowledge. It follows a simple structure with two key functions: setup and loop.
The setup Function
setup() runs once when Arduino starts or resets. It initialises the settings and resources your program needs.
Think of it as setting the stage for the program.
After setup comes loop.
The loop Function

After setup, loop() is called repeatedly while the program runs. Place the main logic here: update values, react to inputs and repeat actions while Arduino is powered.
The image above shows a loop that switches an LED on and off at one-second intervals.
When writing your first program, focus on the required instructions in setup and loop. These basics alone can produce impressive results.
The Code
Let’s jump into the code. It may seem fast, but exploring and seeing what happens is a useful way to learn. We will examine how this project works.
The code is below, and each part is explained. Some words link to Arduino documentation with detailed explanations of the programming concepts. Follow them if you are confused. Do not be intimidated by the amount of information: we have just begun, and there is plenty to learn. With practice, you will soon understand the code!
int soundSensor = 2; // Lydsensoren er tilsluttet pin 2 på Arduino
int LED = 4; // LED'en er tilsluttet pin 4 på Arduino
boolean LEDStatus = false; // Variabel til at holde styr på LED'ens status (tændt/slukket)
void setup() {
pinMode(soundSensor, INPUT); // Indstil lydsensoren som en input-pin
pinMode(LED, OUTPUT); // Indstil LED'en som en output-pin
}
void loop() {
int SensorData = digitalRead(soundSensor); // Læs værdien fra lydsensoren og gem den i variablen SensorData
if (SensorData == 1) { // Hvis lydsensoren registrerer en lyd over tærskelværdien (1)
if (LEDStatus == false) { // Hvis LED'en er slukket
LEDStatus = true; // Sæt LEDStatus til sand (LED'en er tændt)
digitalWrite(LED, HIGH); // Tænd LED'en
delay(200); // Vent i 200 millisekunder
} else {
LEDStatus = false; // Sæt LEDStatus til falsk (LED'en er slukket)
digitalWrite(LED, LOW); // Sluk LED'en
delay(200); // Vent i 200 millisekunder
}
}
}
Start by declaring variables.
“int soundSensor = 2;” says that pin 2 connects the sound sensor, and “int LED = 4;” says that pin 4 connects the LED.
“boolean LEDStatus = false;” creates a variable tracking whether the LED is on or off, initially off (false).
Think of bool as a little box with two states: open or closed. It answers yes/no questions such as “Is the light on?” or “Is the door open?” true means yes, false means no. The bool type is useful for decisions based on such questions.
In void setup(), configure Arduino using the built-in function pinMode().
In pinMode(), the first argument identifies the pin to configure, such as 2 or 4 in our examples with int soundSensor = 2 and int LED = 4.
The second argument to pinMode() specifies whether the pin is input or output. To read values, use INPUT as the second argument. To send or control a state, use OUTPUT as the second argument.
So... pinMode(pinNumber, INPUT/OUTPUT);
In our code, “pinMode(soundSensor, INPUT);” tells Arduino that pin 2, where the sound sensor (soundSensor) connects, is an INPUT. We expect to receive a signal from the sensor on this pin.
“pinMode(LED, OUTPUT);” says that pin 4, where the LED connects, is an OUTPUT. We intend to send a signal to the LED to switch it on or off.
Think of pinMode() as telling Arduino how to treat a pin: is the wire intended to send or receive signals? Imagine a switch selecting “send” or “receive”. pinMode(..., OUTPUT) configures an output; pinMode(..., INPUT) configures an input.
Now we reach void loop(), which repeats. It uses two built-in functions: digitalRead() and digitalWrite().
digitalRead() reads HIGH or LOW from a digital input. Its argument is the pin number to read.digitalWrite() sets a digital output HIGH or LOW. Its two arguments are the pin number and desired state (either HIGH or LOW).
First read the sensor using “int SensorData = digitalRead(soundSensor);”. This reads the logic level at pin 2. The example reacts to HIGH (1); if your module is active LOW, adapt the detection condition accordingly.
Use an “if” statement to decide whether to switch the LED on or off.
An if statement, also called a conditional statement, performs an action only when a condition is satisfied.
The syntax of an if statement in C++ is:
if (betingelse) {
// Udfør handlingen, hvis betingelsen er sand
}
Here is a brief explanation of the parts of the if statement:
-
if: This keyword begins theifstatement and indicates that a condition will be evaluated. - Condition: A logical expression that can be true or false. If true, the action inside the
{}block runs. If false, the{}block is skipped and execution continues after theifstatement. - Action: The code to run if the condition is true. It may be one statement or a block surrounded by
{}.
“if (LEDStatus == false)” checks whether the LED is off. If so, the block runs and LEDStatus becomes true. Send the output using “digitalWrite(LED, HIGH);”, setting pin 4 HIGH to light the LED. Then wait 200 milliseconds with “delay(200);”.
If the LED is already on (LEDStatus is true), the “else” block runs.
else is used with if statements to specify an alternative action when the if condition is false.
The syntax of an if-else statement is:
if (betingelse) {
// Udfør handlingen, hvis betingelsen er sand
} else {
// Udfør denne handling, hvis betingelsen er falsk
}
Here is a brief explanation of the else part of the if-else statement:
-
else: This keyword specifies an alternative action if the associatedifcondition is false. - Action: The code to execute when the associated
ifcondition is false. It may be a single statement or a block surrounded by{}.
Set LEDStatus to false in this branch, then use “digitalWrite(LED, LOW);” to set pin 4 LOW and switch the LED off. Wait another 200 milliseconds with “delay(200);”.
The program returns to loop and repeats, reading sensor data and changing LED state. The 200 ms pause only limits repeated toggles; sustained or noisy active input can toggle again. Reliable one-toggle-per-clap behaviour requires edge detection and suitable timing/filtering.
Uploading the Sketch
Connect Arduino to the computer with a USB cable. Open Arduino IDE and choose the correct board and port.
The IDE may recognise the board automatically. If not, select the actual model manually; for classic UNO choose Arduino AVR Boards > Arduino UNO.
Choose the port corresponding to the connected board. On Windows, Device Manager under Ports (COM & LPT) can help identify it; Linux and macOS use different serial-device names. Reconnecting the board can help identify which port appears.
Once the correct board and port are selected, you are ready to upload.

Figure 4
Two toolbar controls matter: the red circle marks Verify. It compiles and reports compilation errors; it does not test wiring or guarantee correct program behaviour.
The purple circle marks Upload, which transfers the code to Arduino. Click it to begin.
Upload compiles the sketch and transfers it to the board. If successful, test the project’s behaviour.
After uploading, clap or snap your fingers to test it!
You have taken your first steps into electronics. Programming and experimenting are a learning journey. Do not fear mistakes or trying changes to your code. Arduino is a great platform for practical learning, so have fun and learn along the way!