Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Sound-Activated: Controlling Devices with Sound
Introduction: The ability to control devices using sound has become increasingly popular in various applications, such as home automation, robotics, and interactive installations. This article aims to explore the concept of sound-activated control using Arduino, providing examples of code and a list of components required for the projects.
Project: The project we will create as an example is a sound-activated LED strip. The objective is to control the LED strip based on the sound level in the environment. When the sound reaches a certain threshold, the LED strip will turn on, and when the sound level decreases, it will turn off.
Components: To complete this project, you will need the following components:
Examples: Here is an example code that demonstrates the sound-activated LED strip:
#include <Adafruit_NeoPixel.h>
#define PIN_LED_STRIP 6
#define PIN_SOUND_SENSOR A0
Adafruit_NeoPixel strip = Adafruit_NeoPixel(30, PIN_LED_STRIP, NEO_GRB + NEO_KHZ800);
int soundThreshold = 500;
boolean ledState = false;
void setup() {
strip.begin();
strip.show();
pinMode(PIN_SOUND_SENSOR, INPUT);
}
void loop() {
int soundLevel = analogRead(PIN_SOUND_SENSOR);
if (soundLevel > soundThreshold && !ledState) {
strip.fill(strip.Color(255, 0, 0)); // Turn on the LED strip with red color
strip.show();
ledState = true;
}
else if (soundLevel < soundThreshold && ledState) {
strip.fill(strip.Color(0, 0, 0)); // Turn off the LED strip
strip.show();
ledState = false;
}
}
Explanation: