Israel Lopez
Published © GPL3+

Lane Tech HS - PCL - LED Alarm Clock

An Alexa activated alarm clock that when it goes off, LEDs with strobe until the alarm is turned off.

BeginnerFull instructions provided1 hour79
Lane Tech HS - PCL - LED Alarm Clock

Things used in this project

Hardware components

Argon
Particle Argon
×1
LED Strip, 5 m
LED Strip, 5 m
The number of LED strips needed depends on how many you want.
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
MOSFET
×3
Breadboard (generic)
Breadboard (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×3
60W PCIe 12V 5A Power Supply
Digilent 60W PCIe 12V 5A Power Supply
×1
12V DC Power Connector - Female
×1
Echo Dot
Amazon Alexa Echo Dot
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Amazon Alexa service
IFTTT Amazon Alexa service
Time API

Story

Read more

Schematics

Schematics

Code

Alarm clock LED Lights Code

C/C++
Starts the search when Alexa is triggered, strobes LED lights when given time is reached, and turns off LED lights when Alexa is triggered.
#include <ArduinoJson.h>

StaticJsonDocument<801> doc;
const char* main_time = doc["time"];
int firstCheck = Time.minute();
int secondCheck = firstCheck;
int timer = 0;
int RED_LED = 5;
int BLUE_LED = 4;
int GREEN_LED = 6;
bool isOn = false;

void setup()
{
    Particle.function("start", startTime);
    
    Particle.subscribe("hook-response/Time", myHandler, MY_DEVICES);
    Serial.begin(9600);
    Time.beginDST();
    
    pinMode(GREEN_LED, OUTPUT);
    pinMode(RED_LED, OUTPUT);
    pinMode(BLUE_LED, OUTPUT);
}

void loop()
{
    if( isOn )
    {
        
    if(timer > 0)
    {
        analogWrite(RED_LED, 255);
        analogWrite(GREEN_LED, 0);
        analogWrite(BLUE_LED, 0);
        delay(100);
        analogWrite(RED_LED, 0);
        analogWrite(GREEN_LED, 255);
        analogWrite(BLUE_LED, 0);
        delay(100);
        analogWrite(RED_LED, 0);
        analogWrite(GREEN_LED, 0);
        analogWrite(BLUE_LED, 255);
        delay(100);
    }
    else
    {
    if(firstCheck == secondCheck){
    
    firstCheck = Time.minute();
    
    }
    else{
    
    firstCheck = Time.minute();
    secondCheck = firstCheck;
    
    Particle.publish("Time", PRIVATE);
    }
    }
    }
    else{
        timer = 0;
        Particle.publish("Off");
        analogWrite(RED_LED, 0);
        analogWrite(GREEN_LED, 0);
        analogWrite(BLUE_LED, 0);
    }
}

void myHandler(const char *event, const char *data)
{
    const char* json = data;

    deserializeJson(doc, json);

    main_time = doc["time"];
    char wakeUp[] = "15:35";
    
    bool isEqual = strcmp(main_time, wakeUp) == 0;

    Particle.publish(main_time);
    
    if(isEqual)
    {
        timer++;
    }
}

int startTime(String param) {
    
    isOn = !isOn;
    
    return 0;
}

Credits

Israel Lopez
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.