{"id":1364,"date":"2014-05-26T06:10:57","date_gmt":"2014-05-25T21:10:57","guid":{"rendered":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/?page_id=1364"},"modified":"2014-07-18T08:05:08","modified_gmt":"2014-07-17T23:05:08","slug":"7segduino-application-6-gps-clock","status":"publish","type":"page","link":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/aruino\/7segduino\/7segduino-application-6-gps-clock\/","title":{"rendered":"<!--:ja-->7segduino Application (6) GPS Clock<!--:--><!--:en-->7segduino Application (6) GPS Clock<!--:-->"},"content":{"rendered":"<p><!--:ja-->GPS\u3092\u4f7f\u3063\u305f\u30b7\u30f3\u30d7\u30eb\u306a\u6642\u8a08\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9976.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1368\" title=\"GPS in action\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9976-400x264.jpg\" alt=\"GPS in action\" width=\"400\" height=\"264\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9976-400x264.jpg 400w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9976.jpg 640w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p><!--:--><!--more--><!--:ja--><\/p>\n<h2>1. \u56de\u8def\u56f3<\/h2>\n<p>GPS\u306e\u30b7\u30ea\u30a2\u30eb\u51fa\u529b\u30927segduino\u306b\u3064\u306a\u3052\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9988.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1367\" title=\"Scematic\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9988-400x264.png\" alt=\"Scematic\" width=\"400\" height=\"264\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9988-400x264.png 400w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9988-1024x678.png 1024w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u4eca\u56de\u3001\u96fb\u6e90\u306fUSB\u304b\u3089\u3068\u308a\u307e\u3057\u305f\u3002GPS\u306e\u6d88\u8cbb\u96fb\u529b\u304c\u5927\u304d\u3044\u69d8\u3067\u3059\u306e\u3067\u3001\u96fb\u6c60\u3067\u306e\u99c6\u52d5\u306b\u306f\u5de5\u592b\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<h2>2. \u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n<p>\u30b7\u30ea\u30a2\u30eb\u7d4c\u7531\u3067\u9001\u3089\u308c\u3066\u304f\u308b\u60c5\u5831\u304b\u3089\u6642\u523b\u306e\u60c5\u5831\u3060\u3051\u3092\u53d6\u308a\u51fa\u3057\u3066\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002(<a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/gps_7seg.ino\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/a>)<\/p>\n<p>\u6642\u523b\u306f\u4e16\u754c\u6a19\u6e96\u6642(UTC)\u306a\u306e\u3067\u30019\u6642\u9593\u3092\u8db3\u3057\u3066\u65e5\u672c\u6642\u9593(JST)\u306b\u5909\u63db\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\n\/*\r\n GPS clock for 7segduino\r\n 2014\/05\/25\r\n morecat_lab\r\n*\/\r\n\r\n#include &lt;Sseg.h&gt;\r\n\r\n\/\/ offset = 9 hours, JST\r\n#define TIMEZONE 900\r\n\r\nSseg mySseg = Sseg(4, 8, 11, 13, 14, 2, 10, 12, 3, 6, 7, 9);\r\n\r\nlong time = 8888;\r\nint sec = 0;\r\n\r\nvoid setup() {\r\n Serial.begin(9600);\r\n\r\n mySseg.setZeroSupress(0);\r\n mySseg.begin();\r\n\r\n}\r\n\r\nvoid parseLine(char *s) {\r\n char *p;\r\n\r\n p = strtok(s, &quot;,&quot;);\r\n if(strcmp(s, &quot;$GPRMC&quot;) != 0) {\r\n return;\r\n }\r\n p = strtok(NULL, &quot;,&quot;);\r\n time = atol(p) \/ 100 + TIMEZONE;\r\n if (time &gt; 2400) {\r\n time -= 2400;\r\n }\r\n sec\u00a0 = atol(p) % 100;\r\n}\r\n\r\nvoid loop() {\r\n static char buf&#x5B;256];\r\n static int ptr = 0;\r\n\r\n while (Serial.available() &gt; 0) {\r\n if (((buf&#x5B;ptr] = Serial.read()) == '\\n') ||\r\n ((buf&#x5B;ptr] == '\\r'))) {\r\n buf&#x5B;ptr] = 0;\r\n parseLine(buf);\r\n ptr = 0;\r\n } else {\r\n ptr++;\r\n }\r\n }\r\n\r\n mySseg.writeNum(time);\r\n if ((sec % 2) == 0) {\r\n mySseg.setDot(1);\r\n } else {\r\n mySseg.clearDot(1);\r\n }\r\n mySseg.updateWithDelay(3);\r\n}\r\n<\/pre>\n<h2>3. \u5b9f\u88c5<\/h2>\n<p>GPS\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u4ed8\u5c5e\u3057\u3066\u3044\u305f\u30b3\u30cd\u30af\u30bf\u4ed8\u304d\u306e\u30b1\u30fc\u30d6\u30eb\u3092\u5207\u65ad\u3057\u3066\u30017segduino\u306e\u30b3\u30cd\u30af\u30bf\u306b\u63a5\u7d9a\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9985.png\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1369\" title=\"Connector\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9985-400x264.png\" alt=\"Connector\" width=\"400\" height=\"264\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9985-400x264.png 400w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9985.png 640w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u307e\u305f\u3001\u540c\u3058\u30b3\u30cd\u30af\u30bf\u304b\u3089\u96fb\u6e90\u3092\u4f9b\u7d66\u3059\u308b\u305f\u3081\u306e\u30b1\u30fc\u30d6\u30eb\u3082\u51fa\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>FTDI\u30a2\u30c0\u30d7\u30bf\u7d4c\u7531\u30677segduino\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304d\u8fbc\u3093\u3060\u5f8c\u3001\u30b3\u30cd\u30af\u30bf\u3092\u3064\u306a\u3052\u3070\u52d5\u4f5c\u3057\u307e\u3059\u3002<\/p>\n<p>GPS\u304c\u885b\u661f\u3092\u3068\u3089\u3048\u308b\u307e\u30675\u5206\u304b\u308910\u5206\u7a0b\u5ea6\u304b\u304b\u308a\u307e\u3059\u3002<\/p>\n<div id=\"attachment_1366\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9979.jpg\"><img aria-describedby=\"caption-attachment-1366\" loading=\"lazy\" class=\"size-medium wp-image-1366\" title=\"GPS Clock\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9979-400x264.jpg\" alt=\"Simple GPS Clock\" width=\"400\" height=\"264\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9979-400x264.jpg 400w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/05\/IMGP9979.jpg 640w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><p id=\"caption-attachment-1366\" class=\"wp-caption-text\">Simple GPS Clock<\/p><\/div>\n<p>\uff08\u4e86\uff09<!--:--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GPS\u3092\u4f7f\u3063\u305f\u30b7\u30f3\u30d7\u30eb\u306a\u6642\u8a08\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":79,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/pages\/1364"}],"collection":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/comments?post=1364"}],"version-history":[{"count":12,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/pages\/1364\/revisions"}],"predecessor-version":[{"id":1422,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/pages\/1364\/revisions\/1422"}],"up":[{"embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/pages\/79"}],"wp:attachment":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/media?parent=1364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}