Alek Popovic
Published

Light Sensitive Lamp

This project was part of the Lane Tech HS Physical Computing Lab course. I created this project as part of the Home Automation / IoT project

BeginnerFull instructions provided5 hours678
Light Sensitive Lamp

Things used in this project

Hardware components

Photon
Particle Photon
×1
Breadboard (generic)
Breadboard (generic)
×1
Extension Cord (any size)
×1
Lamp (wall plug-in)
×1
Relay (generic)
×1
RobotGeek Light Sensor
RobotGeek Light Sensor
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×10

Software apps and online services

Blynk
Blynk

Story

Read more

Schematics

Light Project Schematic

The battery represents power from a wall socket. Use an extension cord to replace the wires connecting the light bulb, battery, and relay.

Code

Light Project Code

C/C++
Uses the Blynk library on Particle Photon. Make sure to install Blynk app on phone.
#include <blynk.h>

char auth[] = "5b19233c7bc7434d82296562a888b82c";

void setup() {
    
    Serial.begin(9600);
    delay(5000);
    Blynk.begin(auth);
    
    Time.zone(-6);
    
    pinMode(6, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(4, INPUT_PULLDOWN);
    pinMode(3, OUTPUT);
    pinMode(2, INPUT_PULLDOWN);

}

void loop() {
    
    Blynk.run();
    
    if (digitalRead(4) == LOW) {
        
        if (digitalRead(2) == LOW) {
            
            digitalWrite(6, LOW);
            
        } else {
            
            digitalWrite(6, HIGH);
            
        }
        
    } else {
        
        if (Time.hour() == 12 && Time.minute() == 0) { 
            
            digitalWrite(6, HIGH);
            
        } else {
        
            if (analogRead(A0) < 500) {
            
                digitalWrite(6, LOW);
                Serial.println(analogRead(A0));
            
            } else {
            
                digitalWrite(6, HIGH);
                Serial.println(analogRead(A0));
            
            }
            
        }
        
    }
    
}

Credits

Alek Popovic

Alek Popovic

2 projects • 2 followers

Comments

Add projectSign up / Login