动画 RGB 挂钟
组件和用品
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
| × | 1 | ||||
| × | 1 |
必要的工具和机器
![]() |
| |||
![]() |
|
关于这个项目

如果您还记得,我们在前面的部分中介绍了我们的时钟设计项目,如 INFINITY MIRROR CLOCK 和 7-SEGMENT DIGITAL CLOCK。现在我们又来了一款不同的、特别的、非常漂亮的时计。
毫无疑问,您会喜欢这款挂钟。对于这个项目,我们再次使用了 RGB LED。当然,3D 打印机非常重要!我们再次设计并生产了我们的挂钟所需的一些零件。它不仅仅是一个时钟,它还包含不同的动画。如果您愿意,也可以将时钟用作动画。
你问你如何控制这个时钟和动画?别担心。我们为您开发了一个非常简单的应用程序。你可以下载链接。
Arduino是必不可少的。我们使用 Arduino Nano 来节省空间。我们的 RGB WALL CLOCK 项目具有小型电子电路,不会让您失望。我们不想再让您兴奋了,所以我们邀请您观看下面的视频!






代码
- Arduino Nano 代码
Arduino Nano 代码Arduino
时间和动画代码在文件中#include#include #ifdef __AVR__ #include #endif#define PIN 6#define PIN2 7#define NUMPIXELS 60DS3231 rtc(SDA, SCL);时间 t;int hr;int mnt;int sc;char 数据;char color_select;int h_red_deger=255;int h_green_deger=0;int h_blue_deger=0;int m_red_deger=0;int m_green_deger=255; int m_blue_deger=0;int s_red_deger=255;int s_green_deger=255;int s_blue_deger=0;Adafruit_NeoPixel 像素 =Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);Adafruit_2PINEOPixel 像素 =Adafruit_2PINdafruitAdafruit_NeoPixel Adafruit_NeoPixel,NEOZE_2PINDAEOZEOPixel 像素=Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);Adafruit_NeoPixel strip2 =Adafruit_NeoPixel(12, PIN2, NEO_GRB + NEO_KHZ800);int delayval =10;无效设置(){ Serial.begin(9600); rtc.begin();#if defined (__AVR_ATtiny85__) if (F_CPU ==16000000) clock_prescale_set(clock_div_1);#endif // 饰品特殊代码结束pixel.begin(); // 这将初始化 NeoPixel 库。 pixel2.begin(); strip.begin();带.show(); strip2.begin(); strip2.show();//}void loop() { while(Serial.available()> 0) // balant kuruluyken { delay(10); char c =Serial.read();数据=c; if(data=='m') { 数据=''; t =rtc.getTime(); hr=t.hour; mnt=t.min; sc=t.sec; while(data!='m') { data=Serial.read();如果(数据=='+'){ hr++; } if(data=='-') { hr--; } for(int i=0;i<12;i++){pixels2.setPixelColor(i,pixels2.Color(0,255,10));}pixels2.show(); if(hr>=12){hr=hr-12;} if(hr<0){hr=hr+12;} pixel2.setPixelColor(hr, pixel2.Color(255,0,0)); pixel2.show();延迟(100); pixel2.setPixelColor(hr, pixel2.Color(0,0,0)); pixel2.show();延迟(100); } rtc.setTime(hr,mnt,sc); if(data=='m') { 数据=''; t =rtc.getTime(); hr=t.hour; mnt=t.min; sc=t.sec; while(data!='m') { data=Serial.read();如果(数据=='+'){ mnt++; if(mnt==60) {mnt=0;} } if(data=='-') { if(mnt==0) {mnt=60;} mnt--; } for(int k=0;k<60;k++){pixels.setPixelColor(k, pixel.Color(0,0,0));} for(int k=0;k<60;k++){pixels. setPixelColor(k,pixels.Color(25,25,255));k=k+4;}pixels.setPixelColor(mnt,pixels.Color(0,250,0));像素显示();延迟(100); pixel.setPixelColor(mnt, pixel.Color(0,0,0));像素显示();延迟(100); } } rtc.setTime(hr,mnt,sc);数据=''; } if(data=='H') { color_select=data; } if(data=='M') { color_select=data; } if(data=='S') { color_select=data; } if(data=='A') { data=''; colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // 绿色 colorWipe(strip.Color(0, 0, 255), 50); // 蓝色//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW // 在...中发送一个剧院像素追逐... TheaterChase(strip.Color(127, 127, 127), 50); // 白色的 theatreChase(strip.Color(127, 0, 0), 50); // 红色 theatreChase(strip.Color(0, 0, 127), 50); // 蓝色彩虹(20);彩虹循环(20);剧院追逐彩虹(50); } if(data=='r'&&color_select=='H') { h_red_deger=Serial.parseInt(); pixel2.setPixelColor(hr, pixel2.Color(h_red_deger,h_green_deger, h_blue_deger)); pixel2.show(); } if(data=='g'&&color_select=='H') { h_green_deger=Serial.parseInt(); pixel2.setPixelColor(hr, pixel2.Color(h_red_deger,h_green_deger, h_blue_deger)); pixel2.show(); } if(data=='b'&&color_select=='H') { h_blue_deger=Serial.parseInt(); pixel2.setPixelColor(hr, pixel2.Color(h_red_deger,h_green_deger, h_blue_deger)); pixel2.show(); } if(data=='r'&&color_select=='M') { m_red_deger=Serial.parseInt(); pixel.setPixelColor(mnt, pixel.Color(m_red_deger,m_green_deger,m_blue_deger));像素显示(); } if(data=='g'&&color_select=='M') { m_green_deger=Serial.parseInt(); pixel.setPixelColor(mnt, pixel.Color(m_red_deger,m_green_deger,m_blue_deger));像素显示(); } if(data=='b'&&color_select=='M') { m_blue_deger=Serial.parseInt(); pixel.setPixelColor(mnt, pixel.Color(m_red_deger,m_green_deger,m_blue_deger));像素显示(); }if(data=='r'&&color_select=='S') { s_red_deger=Serial.parseInt(); pixel.setPixelColor(sc, pixel.Color(s_red_deger,s_green_deger,s_blue_deger));像素显示(); } if(data=='g'&&color_select=='S') { s_green_deger=Serial.parseInt(); pixel.setPixelColor(sc, pixel.Color(s_red_deger,s_green_deger,s_blue_deger));像素显示(); } if(data=='b'&&color_select=='S') { s_blue_deger=Serial.parseInt(); pixel.setPixelColor(sc, pixel.Color(s_red_deger,s_green_deger,s_blue_deger));像素显示(); } } t =rtc.getTime(); hr=t.hour; mnt=t.min; sc=t.sec; pixel.setPixelColor(sc, pixel.Color(s_red_deger,s_green_deger,s_blue_deger)); pixel.setPixelColor(mnt, pixel.Color(m_red_deger,m_green_deger,m_blue_deger));像素显示(); for(int i=0;i<12;i++){ if(i==hr) {i++;} pixel2.setPixelColor(i, pixel2.Color(0,255,0));} pixel2.show(); if(hr>=12){hr=hr-12;} pixel2.setPixelColor(hr, pixel2.Color(h_red_deger,h_green_deger,h_blue_deger)); pixel2.show();延迟(10); pixel.setPixelColor(sc, pixel.Color(0,0,0)); for(int k=0;k<60;k++){pixels.setPixelColor(k, pixel.Color(0,0,0));} for(int k=0;k<60;k++){pixels.setPixelColor (k,pixels.Color(25,25,255));k=k+4;}pixels.setPixelColor(mnt,pixels.Color(0,0,0));像素显示(); }void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i
示意图

制造工艺