{"id":1127,"date":"2016-09-26T15:45:06","date_gmt":"2016-09-26T07:45:06","guid":{"rendered":"https:\/\/www.webteach.tw\/?p=1127"},"modified":"2016-09-26T15:45:06","modified_gmt":"2016-09-26T07:45:06","slug":"arduino-%e6%95%b8%e4%bd%8d%e6%99%82%e9%90%98-4-digit-display-v1-0-%e9%a1%af%e7%a4%ba%e6%a8%a1%e7%b5%84-rtc-ds3231","status":"publish","type":"post","link":"https:\/\/www.webteach.tw\/?p=1127","title":{"rendered":"[ Arduino ] \u2013 \u6578\u4f4d\u6642\u9418 (4-Digit Display v1.0 \u986f\u793a\u6a21\u7d44 + RTC DS3231 )"},"content":{"rendered":"<p>\t\t\t\t\u8acb\u5148\u53c3\u8003<br \/>\n<a href=\"https:\/\/www.webteach.tw\/?p=1123\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.webteach.tw\/?p=1123<\/a><br \/>\n<a href=\"https:\/\/www.webteach.tw\/?p=1121\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.webteach.tw\/?p=1121<\/a><br \/>\n\u4ee5\u4e0a\u9019\u5169\u7bc7<br \/>\n[javascript]<br \/>\n#include &lt;DS3231.h&gt;<br \/>\nDS3231  rtc(SDA, SCL);<br \/>\nTime  t;<br \/>\n#include &quot;TM1637.h&quot;<br \/>\n#define CLK 2\/\/pins definitions for TM1637 and can be changed to other ports<br \/>\n#define DIO 3<br \/>\nTM1637 tm1637(CLK,DIO);<br \/>\nunsigned char ClockPoint = 1;<br \/>\nvoid setup()<br \/>\n{<br \/>\n  Serial.begin(115200);<br \/>\n  rtc.begin();<br \/>\n  tm1637.init();<br \/>\n  tm1637.set(BRIGHT_TYPICAL);\/\/BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;<br \/>\n}<br \/>\nvoid loop()<br \/>\n{<br \/>\n  char buf_h[2];\/\/\u5c0f\u6642\u66ab\u5b58<br \/>\n  t = rtc.getTime();\/\/\u53d6\u5f97\u6642\u9593<br \/>\n  int h=t.hour;\/\/\u5c0f\u6642<br \/>\n  int h0=h\/10;\/\/\u5c0f\u6642\u7b2c\u4e00\u4f4d<br \/>\n  int h1=h%10;\/\/\u5c0f\u6642\u7b2c\u4e8c\u4f4d<br \/>\n  \/\/Serial.println(h);<br \/>\n  \/\/Serial.println(h0);<br \/>\n  \/\/Serial.print(h1);<br \/>\n  int m=t.min;\/\/\u5206\u9418<br \/>\n  int m0=m\/10;\/\/\u5206\u9418\u7b2c\u4e00\u4f4d<br \/>\n  int m1=m%10;\/\/\u5206\u9418\u7b2c\u4e8c\u4f4d<br \/>\n  \/\/Serial.println(m);<br \/>\n  \/\/Serial.println(m0);<br \/>\n  \/\/Serial.print(m1);<br \/>\n  tm1637.display(0,h0);<br \/>\n  tm1637.display(1,h1);<br \/>\n  tm1637.display(2,m0);<br \/>\n  tm1637.display(3,m1);<br \/>\n  ClockPoint = (~ClockPoint) &amp; 0x01;<br \/>\n  if(ClockPoint)tm1637.point(POINT_ON);<br \/>\n  else tm1637.point(POINT_OFF);<br \/>\n  delay (1000);<br \/>\n}<br \/>\n[\/javascript]\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8acb\u5148\u53c3\u8003 https:\/\/www.webteach&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[904],"class_list":["post-1127","post","type-post","status-publish","format-standard","hentry","category-arduino","tag-904"],"_links":{"self":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/1127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1127"}],"version-history":[{"count":0,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=\/wp\/v2\/posts\/1127\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webteach.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}