Skip to content

Latest commit

 

History

History
58 lines (53 loc) · 1.7 KB

README.md

File metadata and controls

58 lines (53 loc) · 1.7 KB

Emulation library of light day regimen (sunrise – sunset) for Arduino.

It supports smooth increase/decrease of brightness according to established duration.

For what?

This functionality can be useful in projects on birdhouse automatization. For example: regulation light day in hen-house or wakening parrots. During smooth change of brightness, birds don’t feel stress.

How does it work?

Declare regimen:

SunSimulation *s;

First of all we should define time of sunrise and sunset, best place for it is setup() function:

//sunrise time 6:15 am
// 6 — sunrise hour
// 15 – minutes
// sunrise duration 40 minutes
TimeSet *sunrise = new TimeSet(6, 15, 40);

// sunset time 8:42 pm
TimeSet *sunset = new TimeSet(20, 42, 50);

Next step is create regimen and initialize it:

s = new SunSimulation(sunrise, sunset);
s->regimenInit();

Function regimenInit() returns string, which reports about successful or wrong initialization. We can check it:

String message = s->regimenInit();
Serial.println(message);

Now in loop() function we can change variable which responsible for light brightness according to current time.

// 6 – current hour
// 35 – current minute
// 43 – current second
// br – our brightness value

s->changeBrightness(6, 35, 43, &br);
Serial.println(br);

Also we can change our previous regimen during loop() run:

s->reloadRegimen(newSunrise, newSunset);

Note:
We can use another constructor and set brightness variable pointer once. And then invoke changeBrightness with only three parameters.

// second constructor
s = new SunSimulation(sunrise, sunset, &br);

s->changeBrightness(6, 35, 43);

For more details see example