Introduction
A Sound Activated Switch is a fascinating project that uses sound levels to control an electronic device. This project leverages a microphone sensor to detect sound and then activates a switch or relay based on the detected sound level. It's a practical demonstration of how sound can be converted into electrical signals and used to control other components. In this tutorial, we'll walk you through creating a Sound Activated Switch using TinkerCAD and Arduino.
Materials Needed
For this project, you will need:
Arduino Uno
Breadboard
Sound Sensor Module (Microphone)
Relay Module
Jumper Wires
LED (for visual feedback, optional)
Step 1: Setting Up the Components
Arduino and Breadboard: Open TinkerCAD and start a new circuit project. Drag and drop an Arduino Uno and a breadboard onto the workspace.
Sound Sensor Module: This module detects sound levels and outputs a signal to the Arduino.
VCC: Connect to the 5V pin on the Arduino.
GND: Connect to GND on the Arduino.
OUT: Connect to a digital pin on the Arduino (e.g., pin 2).
Relay Module: This module allows the Arduino to control high-power devices.
VCC: Connect to the 5V pin on the Arduino.
GND: Connect to GND on the Arduino.
IN: Connect to a digital pin on the Arduino (e.g., pin 8).
COM: Connect to the common terminal of the device you want to control (e.g., an LED or a power outlet).
NO (Normally Open): Connect to one terminal of the device.
LED (optional): For visual feedback, you can use an LED connected to the relay output to indicate when the relay is activated.
Anode (+): Connect to the relay's NO terminal.
Cathode (-): Connect to GND on the Arduino via a current-limiting resistor (e.g., 220Ω).
Step 2: Wiring Diagram
Ensure your wiring follows these connections:
Sound Sensor Module:
VCC → 5V on Arduino
GND → GND on Arduino
OUT → Digital Pin 2 on Arduino
Relay Module:
VCC → 5V on Arduino
GND → GND on Arduino
IN → Digital Pin 8 on Arduino
COM → Common terminal of the device
NO → One terminal of the device
LED (optional):
Anode (+) → NO terminal of the relay
Cathode (-) → GND on Arduino via a 220Ω resistor
Step 3: Writing the Code
With the components connected, let’s write the Arduino code to control the relay based on sound levels.
const int soundPin = 2; // Sound sensor output pin
const int relayPin = 8; // Relay control pin
int soundThreshold = 100; // Threshold for sound activation (adjust as needed)
void setup() {
pinMode(soundPin, INPUT);
pinMode(relayPin, OUTPUT);
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int soundLevel = digitalRead(soundPin); // Read the sound level
// Debugging information
Serial.print("Sound Level: ");
Serial.println(soundLevel);
if (soundLevel == HIGH) {
// Activate relay if sound level is above the threshold
digitalWrite(relayPin, HIGH);
} else {
// Deactivate relay if sound level is below the threshold
digitalWrite(relayPin, LOW);
}
delay(100); // Short delay for stability
}
Step 4: Simulating the Circuit
After entering the code, click the "Start Simulation" button in TinkerCAD.
Simulate sound by toggling the state of the sound sensor in the TinkerCAD environment. The relay should activate when the sound level is detected (HIGH), and deactivate when there is no sound (LOW).
Observe the LED (if used) for visual feedback indicating when the relay is active.
Step 5: Understanding the Code
Sound Detection: The digitalRead() function reads the output from the sound sensor. When sound is detected, it sets the pin to HIGH.
Relay Control: The digitalWrite() function controls the relay. If sound is detected, the relay is activated (HIGH); otherwise, it is deactivated (LOW).
Serial Debugging: The Serial.print() and Serial.println() functions display the sound level on the Serial Monitor, which helps in debugging and adjusting the sound threshold.
Step 6: Enhancing the System
You can expand this basic Sound Activated Switch with additional features:
Adjustable Threshold: Use a potentiometer to adjust the sound threshold dynamically.
Multiple Devices: Control multiple devices by using additional relays or a relay module with multiple channels.
Advanced Sound Detection: Integrate a more sophisticated sound sensor or filter out background noise for more reliable detection.
Conclusion
You have successfully created a Sound Activated Switch using TinkerCAD and Arduino. This project demonstrates how to use sound to control electronic devices, providing a practical application for sensor integration and relay control.
Want us to guide you through your project or make the project for you ?
Create Various Projects
Check out our Free Arduino Projects Playlist - Arduino Projects
Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects
Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects
Check out our Free IoT Projects Playlist - IoT Projects
Check out our Free Home Automation Projects Playlist - Home Automation Projects
Check out our Free NodeMCu Projects Playlist - NodeMCu Projects
Comments