Deryk Gonzalez
Published

Lane Tech HS - PCL - Home Automated Light Switch

A light switch that can be used without getting up to turn it on or off yourself.

EasyShowcase (no instructions)537
Lane Tech HS - PCL - Home Automated Light Switch

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Photon
Particle Photon
×1
Adafruit Photo Transistor Light Sensor
×1
Adafruit Micro Servo - High Powered, High Torque Metal Gear
×1

Software apps and online services

Particle

Story

Read more

Custom parts and enclosures

Wiring Enclosure

This is a cardboard box that holds all of the wiring and rechargeable battery.
Img 0718 x4jlg6g6jg

Schematics

Automated Light Switch Wiring

This image shows the wiring of the Photon, photo transistor, and servo.
Img 0710 yaoxt9h47o

Code

Home Automated Light Switch Code

Java
This code is used to detect light and move the servo. "Blynk" is the app that I used to trigger the servo by using a virtual button.
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>

int analogPin= A3; //phototransistor connected to analog pin 3
//int RED_LED = 1;
int voltm=0;
Servo theServo;

#define BLYNK_PRINT Serial  
// Set serial output for debug prints
//#define BLYNK_DEBUG      

#include <blynk.h>
char auth[] = "335550083f50448ba1340e320f0b2dae";

void setup()
{
Serial.begin(9600);
//pinMode(RED_LED,OUTPUT);
theServo.attach(A4);
Blynk.begin(auth);
}

BLYNK_WRITE(V1) {
if (param.asInt() == 1 && (voltm<200)
 {
    theServo.write(169);              // tell servo to go to position in variable 
  //  digitalWrite(RED_LED,HIGH);
 }

else
 {
    theServo.write(20);              // tell servo to go to position in variable 
  // digitalWrite(RED_LED,LOW);
 }
}

void loop()
{
voltm=analogRead(analogPin); //read the phototransistor
Serial.println(voltm);
Blynk.run();
}

Credits

Deryk Gonzalez

Deryk Gonzalez

2 projects • 1 follower
A senior at Lane Tech

Comments

Add projectSign up / Login