Pablo Sanchez-HernandezKyle Grogan
Published

Particle Argon Sound Activated LED Strip

Have you ever been too lazy to get up and turn on or off your lights? Then this Sound Activated LED Strip is just for you.

IntermediateShowcase (no instructions)3 hours35
Particle Argon Sound Activated LED Strip

Things used in this project

Hardware components

Argon
Particle Argon
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Comidox High Sensitivity Microphone Sensor AVR PIC Sound Detection Module
×1
Songhe DC 1 Channel Optocoupler 3V/3.3V Relay High Level Driver Module Isolated Drive Control Board
×1
LED (generic)
LED (generic)
Used for testing before LED strip was acquired
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
SparkFun Mini Power Switch - SPDT
×1
5V LED Strip
×1
4 AA Battery Holder Case
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
adafruit

Story

Read more

Schematics

Argon #1 - Sound Senor working with Switch - Circuit Schematic

This image demonstrates the circuit diagrams that can allow replication of project. Pins and components are referred. Color coding is provided.

Argon #2 - Toggle LED Strip working with Switch - Circuit Schematic

This image demonstrates the circuit diagrams that can allow replication of project. Pins and components are referred. Visibility may be obstructed due to scanning software, so legend is provided to identify pins and connections from Argon and Breadboard. Pictures of components are provided above in Story section

Code

Argon #1 - Sound Sensor

C/C++
This argon reads the output signal of the sound sensor when a sound has been received and sends a Particle.publish to toggle the LED light strip
More information on what the code does can be found within the code below.
int Dpin = D0; //reads the soundsensor output 
int val = 0; // the value that the D0 pin reads.
int indicator = D7; // Indicates whether the sound sensor is operable 

void setup() {
    Particle.subscribe("soundsensor_off",SSOFFfunc,MY_DEVICES);
    Particle.subscribe("soundsensor_on", SSONfunc, MY_DEVICES);
    pinMode (Dpin, INPUT);
    pinMode (indicator, OUTPUT);
    digitalWrite(indicator, HIGH);
}
void loop() {
    val = digitalRead(Dpin); // reads the D0 pin.
    if (val == HIGH) {
    Particle.publish("sound_received", PRIVATE);
    delay(1000); // sens a particle publish to the console when the sound sensor picks up a clap or a snap. 
    }
}
void SSOFFfunc(const char *topic, const char *data) {
    pinMode(Dpin, OUTPUT); //when "soundsensor_off" is received in the particle console this function runs which changes the pinmode of D0 to an output, causing the sound sensor to stop receiveng sound, and the indicator light turns off.
    digitalWrite(indicator, LOW);
}
void SSONfunc(const char *topic, const char *data) {
    pinMode(Dpin, INPUT); //when "soundsensor_on" is received in the particle console this function runs which changes the pinmode of D0 to an input, which allows the sound sensor to receive sound again, and the indicator light turns on.
    digitalWrite(indicator, HIGH);
}

Argon #2 - LED Strip with Battery, Relay Module, and Switch.

C/C++
This argon is used to power the LED light strip with the help of a battery connected to a relay module either through the switch or through sound sensor through the Particle.publish and Particle.subscribe functions.
More information on what the code does can be found within the code below.
int LED = D4; // relay module is connected to this pin which controls the LED strip 
int val = 0;  
int switchpin = D0; // the switch is connected here
int val2 = 0; 
int switchpin2 = D6; // an extra variable to allow the switch to turn on and off the LED
void setup() {
Particle.subscribe("sound_received",led_toggle,MY_DEVICES);
pinMode(LED, OUTPUT); 
pinMode(switchpin, INPUT); // allows the argon to read the switch state.
pinMode(switchpin2, OUTPUT); 

}
void led_toggle(const char *topic, const char *data) { // funciton that toggles the LED on and off when the sound_received is sent in the particle console. 
    if (digitalRead(LED) == LOW ) {
    digitalWrite(LED, HIGH); // If the LED is off then this turns the LED on.
    
    }
        else if (digitalRead(LED) == HIGH)  
        digitalWrite(LED, LOW); // IF the LED is on then this turns the LED off.
        
    }
    
void loop() { // This is code for the switch functionallity. 
val2 = digitalRead(switchpin2); //reads the value of D6, this allows the code to only send one publish to console instead of one every 1 second and allows the switch to turn off the light when the switch is turned from on to off. 
val = digitalRead(switchpin); // reads the switch state value
if (val == HIGH && (val2 == LOW)){  // if the switch is in the on position and D6 is at a low state then run the code below. this deactivates the sound sensor 
    digitalWrite(switchpin2, HIGH);// switches the D6 pin to high so that the particle publish only publishes one "sound_output" and it only runs through the if statement once. 
    Particle.publish("soundsensor_off", PRIVATE); // publishes to the console that the sound sensor should be off. 
    digitalWrite(LED, HIGH); // Turns on LED strip 
    delay(1000);
    String data = String(val); 
    Particle.publish("switch_state", data, PRIVATE); // publishes to AdaFruit for graphing. 
    
}
else if (val == LOW && (val2 == HIGH)){ // if the switch is in the off position and D6 is at a high state then run the code below. This activates the sound sensor.
    digitalWrite(switchpin2, LOW); // switches the D6 pin to low so that the particle publish only publishes one "sound_output" and it only runs through the else if statement once.
    Particle.publish("soundsensor_on", PRIVATE); // allows the sound sensor to be read again.  
    digitalWrite(LED, LOW); // turns off the LED strip
    delay(1000);
    String data = String(val);
    Particle.publish("switch_state", data, PRIVATE); // publishes to AdaFruit for graphing.
   
}
}    

Credits

Pablo Sanchez-Hernandez

Pablo Sanchez-Hernandez

1 project • 2 followers
Kyle Grogan

Kyle Grogan

1 project • 2 followers

Comments

Add projectSign up / Login