Nick Udell
Published © GPL3+

Lane Tech HS - PCL - Lamp And Radio Alarm

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.

IntermediateFull instructions provided6 hours736
Lane Tech HS - PCL - Lamp And Radio Alarm

Things used in this project

Hardware components

Photon
Particle Photon
×1
Relay (generic)
×2
extension cord
×1
extension cord
×1
Adafruit Bakelite Universal Perfboard Plate
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Adafruit 36-pin 0.1" Female header
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
×1
Wall Power Adaptor 1 Amp
×1

Software apps and online services

Maker service
IFTTT Maker service

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Cordless Drill

Story

Read more

Schematics

Wiring

Code

Lamp/Radio Alarm

C/C++
int relay1 = D0;
int relay2 = D2;
int btn = D4;
bool lamp = false;
bool radio = false;
bool awake = false;

void setup() {
    pinMode(relay1, OUTPUT);
    pinMode(relay2, OUTPUT);
    pinMode(btn, INPUT_PULLUP);
    Particle.subscribe("time_to_turn_on_lamp", myLamp);
    Particle.subscribe("time_to_turn_on_radio", myRadio);
    Particle.subscribe("lamp_and_radio_reset", myReset);
}

void loop() 
{
    int btnState = digitalRead(btn);
    if(btnState == LOW )
    {
        lamp = false;
        radio = false;
    }
    if(lamp == true)
    {
        digitalWrite(relay1, HIGH);
    }
    else
    {
        digitalWrite(relay1, LOW);
    }
    if(radio == true)
    {
        digitalWrite(relay2, HIGH);
    }
    else
    {
        digitalWrite(relay2, LOW);
    }
    
}
void myLamp(const char *event, const char *data)
{
    lamp = true;
}
void myRadio(const char *event, const char *data)
{
    radio = true;
}
void myReset(const char *event, const char *data)
{
    radio = false;
    lamp = false;
}

Credits

Nick Udell

Nick Udell

3 projects • 1 follower
Student, maker, roboticist, aspiring engineer

Comments