Noah SmithColin Chandler
Published

Clap on/off LED Lights

This project demonstrates how to create clap on/off LED lightstrip. Follow this project to learn to code, wire, and execute smart lights.

BeginnerFull instructions provided478
Clap on/off LED Lights

Things used in this project

Hardware components

Argon
Particle Argon
×2
Breadboard (generic)
Breadboard (generic)
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Elegoo "37 Sensor Kit' - Big Sound
×1
Elegoo "37 Sensor Kit" - Digital Temperature
×1
"DayBetter" - LED Strip Lights Kit
×1
Elegoo "37 Sensor Kit" - RGB LED
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Digilent Screwdriver
Digilent Screwdriver

Story

Read more

Schematics

Digital Temperature Sensor Circuit

Big Sound and RGB LED Circuit Diagram

Code

Clap and Audio Code

C/C++
Overall Audio and Clap code, Look at Circuit for details, and look above to see it broken down
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

int led = D10;
int sound = A0;
boolean trig = false;
boolean state = true;
int sensorPin = A0; //analog --> most helpful when recording realtime data!!
int sensorValue = D0; //define variable to store analog value
TCPClient client;

    unsigned long myChannelNumber = 1937615;
    const char * myWriteAPIKey = "FE32DGAC62TX9SKD";
void setup()
{
   Particle.subscribe("Overheating", Overheating, ALL_DEVICES);
  ThingSpeak.begin(client);
  pinMode(led, OUTPUT);
  pinMode(sound, INPUT);
  Serial.begin(9600);
}

void myHandler(const char *event, const char *data) {
  // Handle the integration response
}

void loop()
{
    sensorValue = analogRead(sensorPin);
    Serial.println(String(sensorValue) );//print analog value onto serial monitor
    delay(1000);
    
    // Get some data
    String data = String(sensorValue);
    // Trigger the integration
    Particle.publish("Sound triggered", data, PRIVATE);
    // Wait 3 seconds
    ThingSpeak.setField(1,data);
    Serial.print(data);
    Serial.println("Sound triggered");
    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
    delay(1000);
    
  trig = digitalRead(sound);
  if(trig == false && state == false)
  {
    digitalWrite(led, HIGH);
    Serial.println("ON");
    state = true;
    delay(500);  
  }
  else if(trig == false && state == true)
  {
    digitalWrite(led, LOW);
    Serial.println("OFF");
    state = false;
    delay(500);
  }  
}

void Overheating(const char*event, const char *data) {
    digitalWrite(led, LOW);
    delay(300);
}

Temperature Code

C/C++
Overall Temperature Code, Look above for more details.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>



int analogvalue = 0;
int temp_f;
TCPClient client;

unsigned long myChannelNumber = 1949556;
const char * myWriteAPIKey = "YBVNRGIJ64C216VI";

void setup(){

  ThingSpeak.begin(client);
  
  Particle.variable("analogvalue", analogvalue);
  Particle.variable("temp_f", temp_f);
 
Serial.begin(9600);

  pinMode(A0, INPUT);
}

void loop()
{
    delay(1500);
  // Read the analog value of the sensor (TMP36)
  analogvalue = analogRead(A0);
  //Convert the reading into degree 
  temp_f = (analogvalue*-.08099688473520249+151.99688473520249); //To be accurate
  //temp = 69;
  
  if (temp_f >= 80) {
      Particle.publish("Overheating", String(temp_f), ALL_DEVICES);
  }
  
  Particle.publish("temperature",String (temp_f), ALL_DEVICES);// sends data to cloud
  ThingSpeak.setField(1,temp_f);
  Serial.print(temp_f);
  Serial.println("temp_f");
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  delay(20000);

}

Credits

Noah Smith

Noah Smith

1 project • 2 followers
Colin Chandler

Colin Chandler

0 projects • 0 followers

Comments