Smart Alarm Clock

An alarm clock that can be snoozed remotely via detection from an IR motion sensor and can report the weather by using a solar panel.

IntermediateFull instructions provided12 hours86
Smart Alarm Clock

Things used in this project

Hardware components

Argon
Particle Argon
×3
Breadboard (generic)
Breadboard (generic)
×3
Resistor 1k ohm
Resistor 1k ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Darlington High Power Transistor
Darlington High Power Transistor
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Clock Diagram

Circuit of the Argon connected directly to the alarm clock

IR Sensor Diagram

Circuit of the Argon connected to the IR sensor

Solar Panel Diagram

Circuit of the Argon connected to the solar panel

Code

Alarm Clock Code

C/C++
///////////////////////////////Clock Code////////////////////////////////////////

int transistor = 5;
int buttRead = 8;
int buttIn = 6;
int light = 7;
void setup() {
    pinMode(transistor ,OUTPUT);
    pinMode(buttRead ,INPUT);
    
    digitalWrite(buttRead ,HIGH);
    digitalWrite(buttIn ,HIGH);
    Particle.subscribe("motion", alarmoff, "E00FCE6858D1F8DFF670B396");
    Particle.subscribe("sunny", yessunny, "E00FCE68138E7EE8D4CEE525");
}

//The D7 light will turn on when the "sunny" event is published

void yessunny(const char *event, const char *data)
{
    digitalWrite(light ,HIGH);
}

//The alarm turns off when the IR sensor detects motion and publishes the "motion" event

void alarmoff(const char *event, const char *data)
{
    digitalWrite(transistor ,HIGH);
    delay(1000);
    digitalWrite(transistor ,LOW);
}


//The event publishes when the button on the board is pressed

void loop() {
    delay(500);
    if (digitalRead(buttRead) == LOW)
        Particle.publish("alarm", PUBLIC);
    else
        delay(500);
  
}

IR Sensor Code

C/C++
////////////////////////////IR Code///////////////////////////////////////////

int light = 7;
int infared = 6;

void setup() {
    pinMode(light ,OUTPUT);
    pinMode(infared ,INPUT);
    Particle.subscribe("alarm", strobe, "E00FCE68C7575C595A7950DF");
    
}

//The "motion" event should publish if the sensor picks up movement

void loop() {
    delay(1000);
    if (digitalRead(infared) == HIGH)
        digitalWrite(light ,HIGH);
    else
        Particle.publish("motion", PUBLIC);
        digitalWrite(light ,LOW);
        
}


//This function makes the D7 LED blink when the alarm goes off

void strobe(const char *event, const char *data)
{
    delay(500);
    digitalWrite(light ,HIGH);
    delay(500);
    digitalWrite(light ,LOW);
    delay(500);
    digitalWrite(light ,HIGH);
    delay(500);
    digitalWrite(light ,LOW);
    delay(500);
    digitalWrite(light ,HIGH);
    delay(500);
    digitalWrite(light ,LOW);
    delay(500);
    digitalWrite(light ,HIGH);
    delay(500);
    digitalWrite(light ,LOW);
    
}

Solar Panel Code

C/C++
////////////////////////////Solar Code//////////////////////////////////////////

int light = 7;
int solar = 6;

void setup() {
    pinMode(light ,OUTPUT);
    pinMode(solar ,INPUT);
    
    Particle.subscribe("alarm", display, "E00FCE68C7575C595A7950DF");
}

//If the panel gives a high enough voltage, the Argon publishes the "sunny" event, which will light up the D7 LED on the clock Argon

void display(const char *event, const char *data)
{
    
        delay(1000);
    if (digitalRead(solar) == HIGH)
    {  digitalWrite(light ,HIGH);
       Particle.publish("sunny", PUBLIC);
       delay(5000);
       digitalWrite(light ,LOW);
    }
    else
        digitalWrite(light ,LOW);
        delay(10000);
    
}


void loop() {

}

Credits

Jason Matthews

Jason Matthews

1 project • 2 followers
cameronclark089

cameronclark089

1 project • 2 followers
Christopher Praisler

Christopher Praisler

1 project • 2 followers

Comments

Add projectSign up / Login