Advertisement
Guest User

Zegar led rgb ring

a guest
Feb 5th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <RTClib.h>
  2. #include <Adafruit_NeoPixel.h>
  3. #include <Wire.h>
  4.  
  5. #define NEOPIN 3
  6. #define BRIGHTNESS 25
  7.  
  8.  
  9. char second1, minute1, hour1;
  10.  
  11. RTC_DS1307 RTC;
  12. DateTime theTime;
  13. Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, NEOPIN, NEO_GRB + NEO_KHZ800);
  14.  
  15. void setup() {
  16. //Zegarek
  17. Serial.begin(9600);
  18. Wire.begin();
  19. RTC.begin();
  20. RTC.adjust(DateTime(__DATE__, __TIME__));
  21. theTime = RTC.now();
  22. RTC.adjust(theTime);
  23. //Wyświetlacz
  24. strip.begin();
  25. strip.setBrightness(BRIGHTNESS);
  26.  
  27.  
  28.  
  29. }
  30.  
  31. void loop() {
  32. //Zegarek  
  33. DateTime now = RTC.now();
  34. Serial.print(now.day(), DEC);
  35. Serial.print('.');
  36. Serial.print(now.month(), DEC);
  37. Serial.print('.');
  38. Serial.print(now.year(), DEC);
  39. Serial.print(' ');
  40. Serial.print(now.hour(), DEC);
  41. Serial.print(':');
  42. Serial.print(now.minute(), DEC);
  43. Serial.print(':');
  44. Serial.print(now.second(), DEC);
  45. Serial.println();
  46. delay(1000);
  47. //Pobiera dane z zegara
  48. second1 = theTime.second();
  49. minute1 = theTime.minute();
  50. hour1 = theTime.hour();
  51. //Wyświetlacz
  52. strip.setPixelColor(second1, 255, 0, 0);
  53. strip.setPixelColor(minute1, 0, 255, 0);
  54. strip.setPixelColor(hour1, 0, 0, 255);
  55.  
  56.  
  57.  
  58. strip.show();
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement