Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Hyuck Choi
Created March 26, 2017

Customizing light arrangement using IoT.

This IoT light customizes light arrangement in a big classroom, which usually has a preset-inefficient arrangement.

Customizing light arrangement using IoT.

Things used in this project

Story

Read more

Schematics

picture of my arduino

sorry i don't remember the exact schematic.

Code

genuino 101 and blynk code for the project

Arduino
it is the complete code for the project.
#define BLYNK_PRINT Serial

#include <BlynkSimpleCurieBLE.h>
#include <CurieBLE.h>

char auth[] = "YourAuthToken";

BLEPeripheral  blePeripheral;

BLYNK_WRITE(V1)
{   
  int value = param.asInt();

  if(value==1){
   digitalWrite(2, HIGH);
   digitalWrite(3, HIGH);
   digitalWrite(4, HIGH);
   digitalWrite(5, HIGH);
  } else{
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  }
}

BLYNK_WRITE(V0)
{   
  int value = param.asInt();

  if(value==1){
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
  } else{
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
  }
  }
  BLYNK_WRITE(V2)
{   
  int value = param.asInt();

  if(value==1){
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
  } else{
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  }
  }
  BLYNK_WRITE(V3)
{   
  int value = param.asInt();

  if(value==1){
    digitalWrite(2, HIGH);
    digitalWrite(4, HIGH);
  } else{
    digitalWrite(2, LOW);
    digitalWrite(4, LOW);
  }
  }
  BLYNK_WRITE(V4)
{   
  int value = param.asInt();

  if(value==1){
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
  } else{
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
  }
  }
  BLYNK_WRITE(V5)
{   
  int value = param.asInt();

  if(value==1){
    digitalWrite(2, HIGH);
    digitalWrite(5, HIGH);
  } else{
    digitalWrite(2, LOW);
    digitalWrite(5, LOW);
  }
  }
  BLYNK_WRITE(V6)
{   
  int value = param.asInt();

  if(value==1){
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
  } else{
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  }
  }
  BLYNK_WRITE(V7)
{   
  int value = param.asInt();

  if(value==1){
    digitalWrite(2, HIGH);
    delay(750);
    digitalWrite(3, HIGH);
    digitalWrite(2, LOW);
    delay(750);
    digitalWrite(5, HIGH);
    digitalWrite(3, LOW);
    delay(750);
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    delay(750);
    digitalWrite(4, LOW);
  }
}


void setup() {
  Serial.begin(9600);
  delay(1000);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  

  blePeripheral.setLocalName("101");
  blePeripheral.setDeviceName("101");
  blePeripheral.setAppearance(384);

  Blynk.begin(blePeripheral, auth);

  blePeripheral.begin();

  Serial.println("Waiting for connections...");
  
}




void loop() {
  Blynk.run();
  blePeripheral.poll();
  
  }

Credits

Hyuck Choi
2 projects • 0 followers

Comments