Advertisement
Guest User

Variante Luce Acquario

a guest
Jul 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1.  
  2. // Arduino - Version: Lastest
  3. #include "arduino.h"
  4.  
  5. // Dusk2Dawn - Version: Latest
  6. #include <math.h>
  7. #include <Dusk2Dawn.h>
  8.  
  9. int piemSunrise = 0;
  10. int piemSunset = 0;
  11.  
  12. // swRTC - Version: Latest
  13. //#define USE_INTERNAL_RTC
  14. #include <core_build_options.h>
  15. #include <swRTC.h>
  16. swRTC rtc; //create a new istance of the lib
  17.  
  18. // RGBLEDBlender - Version: Latest
  19. #include <RGBLEDBlender.h>
  20.  
  21. int val = 0; //Delta time
  22.  
  23.  
  24. /*Comando plaffoniera RGB per acquario con funzione alba e tramonto
  25.  
  26. */
  27.  
  28. void setup() {
  29.  
  30. // Set software RTC
  31. rtc.stopRTC(); //stop the RTC
  32. rtc.setTime(15, 30, 0); //set the time here
  33. rtc.setDate(21, 7, 2017); //set the date here
  34. rtc.startRTC(); //start the RTC
  35.  
  36. // Multiple instances can be created. Arguments are longitude, latitude, and time zone offset in hours from UTC.
  37. Dusk2Dawn piemonte(45.099498, 8.551930, +2);
  38.  
  39. // Available methods are sunrise() and sunset(). Arguments are year, month, day, and if Daylight Saving Time is in effect.
  40. int piemSunrise = piemonte.sunrise(rtc.getYear(), rtc.getMonth(), rtc.getDay(), true);
  41. int piemSunset = piemonte.sunset(rtc.getYear(), rtc.getMonth(), rtc.getDay(), true);
  42.  
  43. Serial.begin(19200); //choose the serial speed here
  44. delay(2000); //delay to let the user opens the serial monitor
  45. }
  46.  
  47. void loop() {
  48. rtc.setDeltaT(val);
  49. rtc.getDeltaT();
  50.  
  51. RGBLEDBlender my_blender(12, 11, 10);
  52.  
  53. /* Funzione ore Dusk2Dawn
  54. * // Time is returned in minutes elapsed since midnight. If no sunrises or
  55. // sunsets are expected, a "-1" is returned.
  56. Serial.println(laSunrise); // 418
  57. Serial.println(laSunset); // 1004
  58. // Serial.println(antSunrise); // -1
  59.  
  60.  
  61. // A static method converts the returned time to a 24-hour clock format.
  62. // Arguments are a character array and time in minutes.
  63. char time[6];
  64. Dusk2Dawn::min2str(time, laSunrise);
  65. Serial.println(time); // 06:58
  66.  
  67. // Alternatively, the array could be initialized with a dummy. This may be
  68. // easier to remember.
  69. char time2[] = "00:00";
  70. Dusk2Dawn::min2str(time2, laSunset);
  71. Serial.println(time2); // 16:53
  72.  
  73. // Do some calculations with the minutes, then convert to time.
  74. int laSolarNoon = laSunrise + (laSunset - laSunrise) / 2;
  75. char time3[] = "00:00";
  76. Dusk2Dawn::min2str(time3, laSolarNoon);
  77. Serial.println(time3); // 11:56
  78. */
  79.  
  80. if (int alba = piemSunrise) {
  81. //Fade through list for T time
  82. my_blender.Blend(_BLACK, _WHITESMOKE, alba); //, _BLUE, _PURPLE, _RED, _ORANGE, _YELLOW
  83. uint32_t blend_time = 1000;
  84. uint32_t done = millis() + blend_time;
  85.  
  86. while (done > millis()) {
  87. my_blender.Update();
  88. }
  89. }
  90. if (int giorno = piemSunset - piemSunrise) {
  91. //Fade through list for T time
  92. my_blender.Blend(_WHITESMOKE, _WHITE, giorno); // _WHITESMOKE
  93. uint32_t blend_time = 1000;
  94. uint32_t done = millis() + blend_time;
  95.  
  96. while (done > millis()) {
  97. my_blender.Update();
  98. }
  99. }
  100. if (int tramonto = piemSunset) {
  101. //Fade through list for T time
  102. my_blender.Blend(_WHITESMOKE _BLACK, tramonto); //, _YELLOW, _ORANGE, _RED, _PURPLE, _BLUE,
  103. uint32_t blend_time = tramonto;
  104. uint32_t done = millis() + blend_time;
  105.  
  106. while (done > millis()) {
  107. my_blender.Update();
  108. }
  109. }
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement