Front view of the Puppy Sound Detecetor in off mode
This Sound & Emotion Detector is designed to sense changes in emotional and speaking volume. Sometimes, when I am talking on the phone with family or friends, my mood may shift and my voice may get louder without me noticing. I also feel bad when I see parents yelling at their children. When people become emotional, they might say things they later regret. I want to create a device that can detect changes in sound and emotion so it can help people become more aware of these moments.
Image of device for overall proportion and scale.
Detail photo of turn on the switch and the power LED lights up.
Image of after detecting the higher sound volume the yellow LED lights up in the eyes.
Image of after detecting the higher sound volume accumulating for than 8 seconds, the red LED lights up in the mouth light turns on and will keep the brightness for 10 seconds.
In this video, I demonstrate how the puppy sound and emotion detector works. When the speaking volume is below the 40 dB threshold, the LEDs in the eye area remain off. When the speaking volume exceeds 40 dB, the eye LEDs turn on. After detecting louder sound (above 40 dB) continuously for more than 8 seconds, the red LED in the mouth area lights up and stays on for 10 seconds.
Basic demo of the sound sensor and LED output
Testing the switch button.
Soldering process
An overall view of the components on a breadboard demo
when switch button is on and the ready for testing sound
In side structure and the each component after soldering
When soldering LEDs, it is important to ensure that the two ends of the resistor are not connected to the same column of voltage and ground. I mistakenly applied the breadboard logic, where power rails have positive and negative sides, to the soldering board. As a result, this caused a short circuit in the LED.
Assembling different modules separately, testing their functionality, and then integrating the entire circuit is an efficient workflow for me. This way helps me better identify issues within individual modules and prevents interference between different module.
Soldering silicone wires is more difficult than regular wires. Although silicone wires are softer and easier to route, they are not friendly for the soldering process.
I’m really glad that everyone had a lot of laughs during my demo and felt that this is a thoughtful and practical project.
When I was doing the breadboard demo, I got the effect I wanted very quickly, and it was stable. But the soldering process took much longer than I expected. I soldered each functional part separately and tested every port to make sure it worked. However, when I put everything together at the end, it still became unstable.
Besides, I realized that when turning an electronic setup into an actual device, planning the wiring and the placement of components is also a very important step.
Giving the device a cute face to characterize it is also helpful for something meant to provide emotional support. Combining the electronic parts with different features of the character, like putting the sound sensor in the “ears” and the indicators in the “eyes”, is an efficient and presentable approach in the design.
During the critique, I got the suggestion to set the environmental base volume first and then detect relative increases. This actually solves a big concern I had. Also, putting the vibration mechanism in the ears is a fun idea—it integrates into the device much better than an external butterfly.
/*
Puppy Sound Detector device for Intro to physical computing project 2
Turn on the switch and the power LED lights up. After detecting the higher sound volume (threshold = 40) the yellow LED lights up in the eyes. After detecting the higher sound volume (threshold = 40) accumulating for than 8 seconds, the red LED lights up in the mouth light turns on and will keep the brightness for 10 seconds.
Some sources that I used:
- ChatPGT helped me set up threshold for volume and correct my code
pin mapping:
Arduino pin | role | description
___________________________________________________________________
A0 input Sound detector
7 output LED for Eyes part
2 output LED for Eyes part
4 output LED for Mouth part
Made by Zixin Ye, zye2@andrew.cmu.edu
*/
"const int envelopePin = A0; // Sound input
const int redLedPin1 = 7; // Light 1 (Red)
const int redLedPin2 = 2; // Light 2 (Red)
const int greenLedPin = 4; // Light 3 (Green)
const int threshold = 40; // Sound volume threshold
const unsigned long requiredHighTime = 8000; // Accumulated high-volume time: 8 seconds
const unsigned long greenLedDuration = 10000; // Green LED duration: 10 seconds
unsigned long highDuration = 0; // Accumulated high-volume time
unsigned long lastMillis = 0; // Time of last loop
unsigned long greenLedStartTime = 0; // Green LED start time
bool isGreenLedActive = false; // Whether green LED is active
bool isGreenLedPreviouslyTriggered = false; // Whether green LED has been triggered before
void setup() {
pinMode(redLedPin1, OUTPUT);
pinMode(redLedPin2, OUTPUT);
pinMode(greenLedPin, OUTPUT);
Serial.begin(9600);
lastMillis = millis();
}
void loop() {
unsigned long now = millis();
unsigned long deltaTime = now - lastMillis; // Time interval of this loop
lastMillis = now;
int soundLevel = analogRead(envelopePin);
Serial.println(soundLevel);
// ---- Green LED duration logic ----
if (isGreenLedActive) {
if (now - greenLedStartTime >= greenLedDuration) {
// Turn off green LED after 10 seconds and reset high-volume timer
digitalWrite(greenLedPin, LOW);
isGreenLedActive = false;
isGreenLedPreviouslyTriggered = true; // Mark green LED as already triggered
highDuration = 0; // Reset accumulated time
}
return; // Do not process red LED logic while green LED is active
}
// ---- Red LED accumulation logic ----
if (soundLevel > threshold) {
// High sound level detected, accumulate time
highDuration += deltaTime;
digitalWrite(redLedPin1, HIGH);
digitalWrite(redLedPin2, HIGH);
} else {
// Sound level below threshold, pause accumulation and turn off red LEDs
digitalWrite(redLedPin1, LOW);
digitalWrite(redLedPin2, LOW);
}
// ---- Green LED trigger logic ----
if (highDuration >= requiredHighTime) {
digitalWrite(greenLedPin, HIGH);
greenLedStartTime = now;
isGreenLedActive = true;
}
// If the green LED has already been triggered and sound stays below threshold,
// reset the accumulated high-volume time
if (isGreenLedPreviouslyTriggered && soundLevel <= threshold) {
highDuration = 0;
}
delay(50);
}
"
Code checked by CHATgpt"