https://github.com/artembotnev/sunsimulation
Sunrise - sunset arduino emulation library
https://github.com/artembotnev/sunsimulation
arduino-library esp32 time
Last synced: about 2 months ago
JSON representation
Sunrise - sunset arduino emulation library
- Host: GitHub
- URL: https://github.com/artembotnev/sunsimulation
- Owner: ArtemBotnev
- License: mit
- Created: 2018-10-16T18:46:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-11T15:04:43.000Z (over 6 years ago)
- Last Synced: 2025-04-09T21:42:54.789Z (about 1 year ago)
- Topics: arduino-library, esp32, time
- Language: C++
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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:
```c++
SunSimulation *s;
```
First of all we should define time of sunrise and sunset, best place for it is setup() function:
```c++
//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:
```c++
s = new SunSimulation(sunrise, sunset);
s->regimenInit();
```
Function regimenInit() returns string, which reports about successful or wrong initialization. We can check it:
```c++
String message = s->regimenInit();
Serial.println(message);
```
Now in loop() function we can change variable which responsible for light brightness according to current time.
```c++
// 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:
```c++
s->reloadRegimen(newSunrise, newSunset);
```
Note:
We can use another constructor and set brightness variable pointer once.
And then invoke changeBrightness with only three parameters.
```c++
// second constructor
s = new SunSimulation(sunrise, sunset, &br);
s->changeBrightness(6, 35, 43);
```
For more details see example