第一次发帖,二进制时钟-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4288|回复: 6

第一次发帖,二进制时钟

[复制链接]
发表于 2016-3-26 21:29 | 显示全部楼层 |阅读模式
一直以来,都是在本论坛学习,至今一直没做出过东西,
废话不多说了,看见其他创客做了二进制时钟,自己也想做个,
没想到慢慢就做成了,虽然代码都是组装的,但是以后一定要自己写代码
硬件ds1307
uno
max7219点阵模块
UNO与ds1307连线
SDA(A4)-SDA
SCK(A5)-SCK
max7219模块与UNO连接
10-CS
11-CLK
12-DIN

 楼主| 发表于 2016-3-26 21:48 | 显示全部楼层
file:///C:\Users\耀凯\Documents\Tencent Files\1643453868\Image\C2C\AF45EEBC14BB2D5F6029EA75968BCBC3.jpgfile:///C:\Users\耀凯\Documents\Tencent Files\1643453868\Image\C2C\AF45EEBC14BB2D5F6029EA75968BCBC3.jpg

就这样

就这样


 楼主| 发表于 2016-3-26 21:32 | 显示全部楼层


  1. 向时钟芯片写时间2016.326.20.56
  2. /****************************************************************************/       
  3. //        Function: Set time and get the time from RTC chip(DS1307) and display
  4. //                          it on the serial monitor.
  5. //        Hardware: RTC by Catalex
  6. //        Arduino IDE: Arduino-1.0
  7. //        Author:         Fred.Chu               
  8. //        Date:          April 19,2013
  9. //        Version: v1.0
  10. //  by catalex.taobao.com
  11. //
  12. //  This library is free software; you can redistribute it and/or
  13. //  modify it under the terms of the GNU Lesser General Public
  14. //  License as published by the Free Software Foundation; either
  15. //  version 2.1 of the License, or (at your option) any later version.
  16. //
  17. //  This library is distributed in the hope that it will be useful,
  18. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20. //  Lesser General Public License for more details.
  21. //
  22. //  You should have received a copy of the GNU Lesser General Public
  23. //  License along with this library; if not, write to the Free Software
  24. //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  25. //
  26. /****************************************************************************/
  27. #include <Wire.h>
  28. #include "DS1307.h"

  29. DS1307 clock;//define a object of DS1307 class
  30. void setup()
  31. {
  32.         Serial.begin(9600);
  33.         clock.begin();
  34.         clock.fillByYMD(2016,3,26);//Jan 19,2013
  35.         clock.fillByHMS(20,56,30);//15:28 30"
  36.         clock.fillDayOfWeek(SAT);//Saturday
  37.         clock.setTime();//write time to the RTC chip
  38. }
  39. void loop()
  40. {

  41. }
  42.         /*printTime();
  43. }
  44. /*Function: Display time on the serial monitor*/
  45. void printTime()
  46. {
  47.         clock.getTime();
  48.         Serial.print(clock.hour);
  49.         Serial.print(":");
  50.         /*Serial.print(clock.minute, DEC);
  51.         Serial.print(":");
  52.         Serial.print(clock.second, DEC);
  53.         Serial.print("        ");
  54.         Serial.print(clock.month, DEC);
  55.         Serial.print("/");
  56.         Serial.print(clock.dayOfMonth, DEC);
  57.         Serial.print("/");
  58.         Serial.print(clock.year+2000, DEC);
  59.         Serial.print(" ");
  60.         switch (clock.dayOfWeek)// Friendly printout the weekday
  61.         {
  62.                 case MON:
  63.                   Serial.print("MON");
  64.                   break;
  65.                 case TUE:
  66.                   Serial.print("TUE");
  67.                   break;
  68.                 case WED:
  69.                   Serial.print("WED");
  70.                   break;
  71.                 case THU:
  72.                   Serial.print("THU");
  73.                   break;
  74.                 case FRI:
  75.                   Serial.print("FRI");
  76.                   break;
  77.                 case SAT:
  78.                   Serial.print("SAT");
  79.                   break;
  80.                 case SUN:
  81.                   Serial.print("SUN");
  82.                   break;
  83.         }
  84.         Serial.println(" ");*/
  85. }
复制代码
 楼主| 发表于 2016-3-26 21:40 | 显示全部楼层

  1. 再将时间读出来即可
  2. /****************************************************************************/  
  3. //  Function: Set time and get the time from RTC chip(DS1307) and display
  4. //        it on the serial monitor.
  5. //  Hardware: RTC by Catalex
  6. //  Arduino IDE: Arduino-1.0
  7. //  Author:  Fred.Chu   
  8. //  Date:    April 19,2013
  9. //  Version: v1.0
  10. //  by catalex.taobao.com
  11. //
  12. //  This library is free software; you can redistribute it and/or
  13. //  modify it under the terms of the GNU Lesser General Public
  14. //  License as published by the Free Software Foundation; either
  15. //  version 2.1 of the License, or (at your option) any later version.
  16. //
  17. //  This library is distributed in the hope that it will be useful,
  18. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20. //  Lesser General Public License for more details.
  21. //
  22. //  You should have received a copy of the GNU Lesser General Public
  23. //  License along with this library; if not, write to the Free Software
  24. //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  25. //
  26. /****************************************************************************/
  27. #include <Wire.h>
  28. #include "DS1307.h"
  29. #include <LedControl.h>

  30. DS1307 clock;//define a object of DS1307 class
  31. LedControl lc=LedControl(12,11,10,1);    //实例化一个LedControl类的对象
  32. void setup()
  33. {
  34.   Serial.begin(9600);
  35. clock.begin();
  36.   lc.setIntensity(0,3);
  37.   lc.shutdown(0,false);
  38. lc.clearDisplay(0);
  39. }
  40. void loop()
  41. {
  42.   clock.getTime();
  43. // int i=clock.second%10;
  44.   //int j=clock.second/10;
  45. // int k=clock.minute%10;
  46. // int q=clock.minute/10;
  47. lc.setColumn(0,7,byte(clock.second%10));  //在4位数码管的第0位(左数第一位)显示秒的个位
  48.   lc.setColumn(0,6,byte(clock.second/10)); //在4位数码管的第1位(左数第二位)显示秒的十位
  49.   lc.setColumn(0,4,byte(clock.minute%10)); //在4位数码管的第2位(左数第三位)显示分的个位
  50.   lc.setColumn(0,3,byte(clock.minute/10)); //在4位数码管的第3位(左数第四位)显示分的十位
  51.   lc.setColumn(0,1,byte(clock.hour%10));//时的个位
  52.   lc.setColumn(0,0,byte(clock.hour/10));//时的十位
  53.   //Serial.print(clock.hour, DEC);
  54. //  printTime();
  55. }
  56. /*Function: Display time on the serial monitor*/
  57. /*void printTime()
  58. {
  59.   clock.getTime();
  60.   Serial.print(clock.hour, DEC);
  61.   Serial.print(":");
  62.   Serial.print(clock.minute, DEC);
  63.   Serial.print(":");
  64.   Serial.print(clock.second, DEC);
  65.   Serial.print("  ");
  66.   Serial.print(clock.month, DEC);
  67.   Serial.print("/");
  68.   Serial.print(clock.dayOfMonth, DEC);
  69.   Serial.print("/");
  70.   Serial.print(clock.year+2000, DEC);
  71.   Serial.print(" ");
  72.   switch (clock.dayOfWeek)// Friendly printout the weekday
  73.   {
  74.     case MON:
  75.       Serial.print("MON");
  76.       break;
  77.     case TUE:
  78.       Serial.print("TUE");
  79.       break;
  80.     case WED:
  81.       Serial.print("WED");
  82.       break;
  83.     case THU:
  84.       Serial.print("THU");
  85.       break;
  86.     case FRI:
  87.       Serial.print("FRI");
  88.       break;
  89.     case SAT:
  90.       Serial.print("SAT");
  91.       break;
  92.     case SUN:
  93.       Serial.print("SUN");
  94.       break;
  95.   }
  96.   Serial.println(" ");
  97. }*/
复制代码

LedControl库
ds1307库我忘了链接在哪了,谁需要联系我
http://playground.arduino.cc/Main/LedControl#Source
发表于 2016-5-21 18:08 | 显示全部楼层
朋友你好,请问arduino uno与max7219如何连接


 楼主| 发表于 2016-6-1 18:52 | 显示全部楼层
max7219模块与UNO连接 10-CS 11-CLK 12-DIN
 楼主| 发表于 2016-6-1 18:55 | 显示全部楼层
我用的是模块化的点阵
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 14:41 , Processed in 0.083398 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表