BrigittaAnjila Bista
Published

Couples IoT light

This is an IOT project for MEGR 3171 where two argons communicate with each other to light up LEDs on each other's particle argon device.

BeginnerWork in progress251
Couples IoT light

Things used in this project

Hardware components

Argon
Particle Argon
×2
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×2
5mm Round Top UV / Purple LED - Ultra Bright
×6
5mm Round Top – Blue / Red Alternating Flashing LED – 1.5Hz - Ultra Bright
×2
Pulse Sensor Heart Rate Sensor
×2
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

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

Story

Read more

Schematics

Coupleslight with heartbeat sensor schematic

This is the circuit diagram for a couples light with a heartbeat sensor integrated. All of the pin configurations are true to the breadboard

Flow Chart

This is a process flow chart of the IoT couples communication device and all of the details on how it functions.

Code

Couple Light 1 code

C/C++
Code for the first Couple light device.
int led2 = D6;
int led3 = D5;
int led4 = D3;
int button = D4;
int heartbeat = A1;
int pulse;
int digitalValue;
void setup() {
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(button, INPUT);
  pinMode(heartbeat, INPUT);
 Particle.subscribe("hook-response/button2", myHandler3, MY_DEVICES);
   // Subscribe to the integration response event
  Particle.subscribe("hook-response/pulse2", myHandler4, MY_DEVICES);
    
    Particle.subscribe("button2", myHandler3, MY_DEVICES);
    Particle.subscribe("pulse2", myHandler4, MY_DEVICES);

}

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

    digitalWrite(led3, HIGH);
    delay(5000);
    digitalWrite(led3, LOW);
    delay(500);
    digitalWrite(led2, HIGH);
    delay(500);
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led4, HIGH);
    delay(500);
    digitalWrite(led4, LOW);

  
}      

void myHandler4(const char *event, const char *data) {
  // Handle the integration response
      digitalWrite(led2, HIGH);
      delay(100);
      
     digitalWrite(led2, LOW);
}      


 void loop() {
 pulse = analogRead(heartbeat);
 digitalValue = digitalRead(button);
  if (digitalValue == 0) {
    String data = String(10);
      Particle.publish("button1", String(button));
    digitalWrite(led3, HIGH);
    delay(5000);
    digitalWrite(led3, LOW);
    delay(500);
    digitalWrite(led2, HIGH);
    delay(500);
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led4, HIGH);
    delay(500);
    digitalWrite(led4, LOW);
    delay(500);
  }  else{
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led3, LOW);
    delay(500);
    digitalWrite(led4, LOW);
    delay(500);
 }



  if (pulse > 2400) {
      Particle.publish("pulse1", String(pulse));
      digitalWrite(led2, HIGH);
      delay(100);
     digitalWrite(led2, LOW);
      
  }
}

Couple Light 2 code

C/C++
Code for the second couple light device
int led2 = D6;
int led3 = D5;
int led4 = D3;
int button = D4;
int heartbeat = A1;
int pulse;
int digitalValue;
void setup() {
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(button, INPUT);
  pinMode(heartbeat, INPUT);
 Particle.subscribe("hook-response/button2", myHandler1, MY_DEVICES);
   // Subscribe to the integration response event
 Particle.subscribe("hook-response/pulse2", myHandler2, MY_DEVICES);
    
    Particle.subscribe("button1", myHandler1, MY_DEVICES);
    Particle.subscribe("pulse1", myHandler2, MY_DEVICES);

}

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

    digitalWrite(led2, HIGH);
    delay(5000);
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led3, HIGH);
    delay(500);
    digitalWrite(led3, LOW);
    delay(500);
    digitalWrite(led4, HIGH);
    delay(500);
    digitalWrite(led4, LOW);
    
  
  
}   

void myHandler2(const char *event, const char *data) {
  // Handle the integration response
      digitalWrite(led3, HIGH);
      delay(100);
     digitalWrite(led3, LOW);
}      


 void loop() {
 pulse = analogRead(heartbeat);
 digitalValue = digitalRead(button);
  if (digitalValue == 0) {
    String data = String(10);
      Particle.publish("button2", String(pulse));
    digitalWrite(led3, HIGH);
    delay(5000);
    digitalWrite(led3, LOW);
    delay(500);
    digitalWrite(led2, HIGH);
    delay(500);
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led4, HIGH);
    delay(500);
    digitalWrite(led4, LOW);
    delay(500);
  }  else{
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led3, LOW);
    delay(500);
    digitalWrite(led4, LOW);
    delay(500);
 }


  if (pulse > 2400) {
      Particle.publish("pulse2", String(pulse));
      digitalWrite(led2, HIGH);
      delay(100);
     digitalWrite(led2, LOW);
      
  }
 }

Credits

Brigitta

Brigitta

1 project • 0 followers
Anjila Bista

Anjila Bista

1 project • 0 followers

Comments

Add projectSign up / Login