Eric GarciaEricDaniel Law
Created February 2, 2022

Lane Tech Sleep Reminder lights

I often forget what time it is while working at my desk, now I get lights that yell at me to go to bed.

Lane Tech Sleep Reminder lights

Things used in this project

Hardware components

Argon
Particle Argon
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
SparkFun USB Type A Female Breakout
SparkFun USB Type A Female Breakout
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Sleep Lights

C/C++
    int led = 2;           
    int Pl = 0;    //Birghtness
    int Ff = 5;  //fade factor
    int b = 6;
    bool status = true;
void setup() {
    Time.zone(- 6);

  pinMode(led, OUTPUT);
  pinMode(b, INPUT_PULLUP);
  
}
void loop() {
    analogWrite(led, Pl);
    int btnState = digitalRead(b);
    if ( btnState == LOW )
	{
	    status = !status;
	    
	}
		
if (Time.hour() == 23 && Time.minute() == 38 && status)
  {
  // fade
  Pl = Pl + Ff;

  // reverse 
  if (Pl <= 0 || Pl >= 255) {
    Ff = -Ff;
  
  delay(100); //so while Ff controls the value of the output brightness each time this also controls the speed at which the whole loop goes
  }
  
  }
   else if(Time.hour() == 0 && Time.minute() == 00){
       status = false;
       
   }
  else if(status)
  {
     digitalWrite(led, HIGH);
  }


}

Credits

Eric Garcia
1 project • 0 followers
Contact
Eric
1 project • 0 followers
Contact
Daniel Law
47 projects • 10 followers
Teacher. Maker. Citizen of the planet.
Contact

Comments

Please log in or sign up to comment.