Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Arduino - Version: Lastest
- #include "arduino.h"
- // Dusk2Dawn - Version: Latest
- #include <math.h>
- #include <Dusk2Dawn.h>
- int piemSunrise = 0;
- int piemSunset = 0;
- // swRTC - Version: Latest
- //#define USE_INTERNAL_RTC
- #include <core_build_options.h>
- #include <swRTC.h>
- swRTC rtc; //create a new istance of the lib
- // RGBLEDBlender - Version: Latest
- #include <RGBLEDBlender.h>
- int val = 0; //Delta time
- /*Comando plaffoniera RGB per acquario con funzione alba e tramonto
- */
- void setup() {
- // Set software RTC
- rtc.stopRTC(); //stop the RTC
- rtc.setTime(15, 30, 0); //set the time here
- rtc.setDate(21, 7, 2017); //set the date here
- rtc.startRTC(); //start the RTC
- // Multiple instances can be created. Arguments are longitude, latitude, and time zone offset in hours from UTC.
- Dusk2Dawn piemonte(45.099498, 8.551930, +2);
- // Available methods are sunrise() and sunset(). Arguments are year, month, day, and if Daylight Saving Time is in effect.
- int piemSunrise = piemonte.sunrise(rtc.getYear(), rtc.getMonth(), rtc.getDay(), true);
- int piemSunset = piemonte.sunset(rtc.getYear(), rtc.getMonth(), rtc.getDay(), true);
- Serial.begin(19200); //choose the serial speed here
- delay(2000); //delay to let the user opens the serial monitor
- }
- void loop() {
- rtc.setDeltaT(val);
- rtc.getDeltaT();
- RGBLEDBlender my_blender(12, 11, 10);
- /* Funzione ore Dusk2Dawn
- * // Time is returned in minutes elapsed since midnight. If no sunrises or
- // sunsets are expected, a "-1" is returned.
- Serial.println(laSunrise); // 418
- Serial.println(laSunset); // 1004
- // Serial.println(antSunrise); // -1
- // A static method converts the returned time to a 24-hour clock format.
- // Arguments are a character array and time in minutes.
- char time[6];
- Dusk2Dawn::min2str(time, laSunrise);
- Serial.println(time); // 06:58
- // Alternatively, the array could be initialized with a dummy. This may be
- // easier to remember.
- char time2[] = "00:00";
- Dusk2Dawn::min2str(time2, laSunset);
- Serial.println(time2); // 16:53
- // Do some calculations with the minutes, then convert to time.
- int laSolarNoon = laSunrise + (laSunset - laSunrise) / 2;
- char time3[] = "00:00";
- Dusk2Dawn::min2str(time3, laSolarNoon);
- Serial.println(time3); // 11:56
- */
- if (int alba = piemSunrise) {
- //Fade through list for T time
- my_blender.Blend(_BLACK, _WHITESMOKE, alba); //, _BLUE, _PURPLE, _RED, _ORANGE, _YELLOW
- uint32_t blend_time = 1000;
- uint32_t done = millis() + blend_time;
- while (done > millis()) {
- my_blender.Update();
- }
- }
- if (int giorno = piemSunset - piemSunrise) {
- //Fade through list for T time
- my_blender.Blend(_WHITESMOKE, _WHITE, giorno); // _WHITESMOKE
- uint32_t blend_time = 1000;
- uint32_t done = millis() + blend_time;
- while (done > millis()) {
- my_blender.Update();
- }
- }
- if (int tramonto = piemSunset) {
- //Fade through list for T time
- my_blender.Blend(_WHITESMOKE _BLACK, tramonto); //, _YELLOW, _ORANGE, _RED, _PURPLE, _BLUE,
- uint32_t blend_time = tramonto;
- uint32_t done = millis() + blend_time;
- while (done > millis()) {
- my_blender.Update();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement