
{"id":6487,"date":"2017-10-05T17:14:33","date_gmt":"2017-10-05T08:14:33","guid":{"rendered":"https:\/\/okiraku-camera.tokyo\/blog\/?p=6487"},"modified":"2020-03-01T22:55:35","modified_gmt":"2020-03-01T13:55:35","slug":"%e3%82%bf%e3%83%83%e3%83%81%e3%83%91%e3%83%8d%e3%83%ab%e4%bb%98tft%e6%b6%b2%e6%99%b6%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%81%a7%e8%b5%a4%e5%a4%96%e7%b7%9a%e3%83%aa%e3%83%a2%e3%82%b3","status":"publish","type":"post","link":"https:\/\/okiraku-camera.tokyo\/blog\/?p=6487","title":{"rendered":"\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u4ed8TFT\u6db2\u6676\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u307f\u308b"},"content":{"rendered":"<h1>\u6982\u8981<\/h1>\n<p>\u4ee5\u524d\u306bamazon\u3067\u5b89\u304f\u8cb7\u3063\u305f2.4\u30a4\u30f3\u30c1\u306eTFT\u6db2\u6676\u30e2\u30b8\u30e5\u30fc\u30eb(\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u4ed8)\u3092Arduino PRO MINI\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3063\u3066\u307f\u305f\u3002\u524d\u304b\u3089\u305f\u307e\u306b\u4f5c\u3063\u3066\u3044\u308b\u8d64\u5916\u7dda\u30ea\u30e2\u30b3\u30f3\u306e\u64cd\u4f5c\u90e8\u3092\u3001\u30e1\u30ab\u30cb\u30ab\u30eb\u30b9\u30a4\u30c3\u30c1\u3067\u306f\u306a\u304f\u3066GUI (!!) \u306b\u3067\u304d\u306a\u3044\u3082\u306e\u304b\u3001\u3068\u8003\u3048\u305f\u306e\u304c\u304d\u3063\u304b\u3051\u3060\u3063\u305f\u3002\u6db2\u6676\u306e\u4e0a\u306b\u5bfe\u8c61\u306b\u5fdc\u3058\u305f\u64cd\u4f5c\u30dc\u30bf\u30f3\u3092\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308c\u3070\u30011\u53f0\u3067\u8907\u6570\u306e\u5bb6\u96fb\u88fd\u54c1\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u308f\u3051\u3067\u3042\u308b\u3002<\/p>\n<p>ESP-WROOM-02\u306a\u3069\u306eWiFi\u6a5f\u80fd\u306e\u3042\u308b\u30de\u30a4\u30b3\u30f3\u306b\u8d64\u5916\u7dda\u9001\u51fa\u6a5f\u80fd\u3092\u4f5c\u308a\u8fbc\u307f\u3001\u30b9\u30de\u30db\u306e\u753b\u9762\u306b\u64cd\u4f5c\u30d1\u30cd\u30eb\u3092\u8868\u793a\u3057\u3066http\u7d4c\u7531\u3067\u30b3\u30de\u30f3\u30c9\u3092\u9001\u308b\u3084\u308a\u65b9\u306f<a href=\"https:\/\/okiraku-camera.tokyo\/blog\/?p=4883\">\u4ee5\u524d\u306b\u3084\u3063\u305f<\/a>\u3002\u6b8b\u5ff5\u306a\u304c\u3089\u3001WROOM-02\u5074\u306fWiFi\u30a2\u30af\u30bb\u30b9\u30dd\u30a4\u30f3\u30c8\u3068\u3057\u3066\u5e38\u6642\u5f85\u3061\u53d7\u3051\u308b\u90fd\u5408\u4e0a\u3001AC\u30a2\u30c0\u30d7\u30bf\u3092\u4f7f\u3063\u305f\u304c\u3001\u3067\u304d\u308c\u3070\u96fb\u6c60\u3067\u52d5\u304b\u3057\u305f\u3044\u3057\u305d\u308c\u306a\u308a\u306b\u96fb\u6c60\u3092\u9577\u6301\u3061\u3055\u305b\u305f\u3044\u3002TFT\u6db2\u6676\u306f\u96fb\u529b\u6d88\u8cbb\u304c\u591a\u3044\u3053\u3068\u306f\u5206\u304b\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u306e\u3042\u305f\u308a\u304c\u30dd\u30a4\u30f3\u30c8\u306b\u306a\u308b\u3060\u308d\u3046\u306a\u3068\u304b\u601d\u3044\u306a\u304c\u3089\u4f5c\u308a\u59cb\u3081\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u8a66\u4f5c\u3057\u305f\u56de\u8def\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u7528\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u304a\u3088\u3073\u30c6\u30b9\u30c8\u7528\u30b9\u30b1\u30c3\u30c1\u306b\u3064\u3044\u3066\u3067\u3001\u30ea\u30e2\u30b3\u30f3\u306b\u306f\u306a\u3063\u3066\u3044\u306a\u3044\u3002<\/p>\n<h1>\u69cb\u6210<\/h1>\n<p>\u30de\u30a4\u30b3\u30f3\u306b\u306fArduino PRO MINI\u306e3.3V\u7248(The Simple, 8MHz)\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u305f\u3002<a href=\"https:\/\/okiraku-camera.tokyo\/blog\/?p=6352\">\u4ee5\u524d\u306e\u8d64\u5916\u7dda\u30ea\u30e2\u30b3\u30f3<\/a>\u3068\u540c\u69d8\u306b\u3001\u7701\u96fb\u529b\u306e\u305f\u3081\u306b\u57fa\u677f\u4e0a\u306ePON LED(\u306e\u76f4\u5217\u62b5\u6297)\u3068+3.3V\u51fa\u529b\u306e\u5b9a\u96fb\u5727\u30ec\u30ae\u30e5\u30ec\u30fc\u30bf\u306f\u9664\u53bb\u3057\u3066\u4f7f\u3046\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<figure id=\"attachment_6492\" aria-describedby=\"caption-attachment-6492\" style=\"width: 552px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/09\/2c0d3638b4e0c04662bbe3aa43708472.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-6492\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/09\/2c0d3638b4e0c04662bbe3aa43708472-552x414.jpg\" alt=\"Arduino PRO MINI\" width=\"552\" height=\"414\" \/><\/a><figcaption id=\"caption-attachment-6492\" class=\"wp-caption-text\">Arduino PRO MINI<\/figcaption><\/figure>\n<p>\u30ec\u30ae\u30e5\u30ec\u30fc\u30bf\u3068\u62b5\u6297\u3092\u5916\u3057\u305f\u3068\u3053\u308d\u3002\u6570mA\u306e\u7bc0\u7d04\u306b\u3059\u304e\u306a\u3044\u304c\u96fb\u6c60\u99c6\u52d5\u306e\u305f\u3081\u306b\u4f59\u8a08\u306a\u3082\u306e\u306f\u5916\u3057\u305f\u3002<\/p>\n<h2>\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u4ed8TFT\u6db2\u6676\u30e2\u30b8\u30e5\u30fc\u30eb<\/h2>\n<p>\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u4ed8\u306eTFT\u6db2\u6676\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3057\u3066\u3001SPI\u63a5\u7d9a\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u4ed82.4\u30a4\u30f3\u30c1TFT\u6db2\u6676\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u00a0<strong>TJCTM24024-SPI\u00a0<\/strong>\u3068\u3044\u3046\u88fd\u54c1\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u305f(\u4ee5\u4e0b\u3001<strong>TFT\u30e2\u30b8\u30e5\u30fc\u30eb<\/strong>\u3068\u8a18\u8ff0\u3059\u308b)\u3002amazon\u3067\u8cfc\u5165\u3057\u305f\u3068\u304d\u306f700\u5186\u7a0b\u5ea6\u3060\u3063\u305f\u3068\u601d\u3046\u3002\u3044\u307e\u691c\u7d22\u3057\u3066\u307f\u305f\u3089\u3001\u5546\u54c1\u81ea\u4f53\u304c\u6d88\u3048\u3066\u3044\u305f\u3002Aliexpress\u3067\u306f\u58f2\u3063\u3066\u3044\u308b\u3088\u3046\u3060\u304c\u3002<\/p>\n<figure id=\"attachment_6490\" aria-describedby=\"caption-attachment-6490\" style=\"width: 552px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/09\/25836c36df9039bb1506d5d752aca749.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-6490\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/09\/25836c36df9039bb1506d5d752aca749-552x414.jpg\" alt=\"TJCTM24024\" width=\"552\" height=\"414\" \/><\/a><figcaption id=\"caption-attachment-6490\" class=\"wp-caption-text\">TJCTM24024<\/figcaption><\/figure>\n<figure id=\"attachment_6491\" aria-describedby=\"caption-attachment-6491\" style=\"width: 552px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/09\/bb4330f155dbf3572024b26ba128dfab.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-6491\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/09\/bb4330f155dbf3572024b26ba128dfab-552x414.jpg\" alt=\"TJCTM24024\" width=\"552\" height=\"414\" \/><\/a><figcaption id=\"caption-attachment-6491\" class=\"wp-caption-text\">TJCTM24024<\/figcaption><\/figure>\n<p>\u4f8b\u306b\u3088\u3063\u3066\u3061\u3083\u3093\u3068\u3057\u305f\u8cc7\u6599\u304c\u306a\u3044\u306e\u3060\u304c\u3001\u96fb\u6e90\u96fb\u5727\u306f+3.3V\u304c\u6a19\u6e96\u306e\u3088\u3046\u3067\u3042\u308b\u3002+5V\u96fb\u6e90\u306eArduino\u3068\u63a5\u7d9a\u3059\u308b\u3068\u304d\u306b\u306f\u30ec\u30d9\u30eb\u5909\u63db\u304c\u5fc5\u8981\u306b\u306a\u308b\u3053\u3068\u306b\u6ce8\u610f\u3002<br \/>\n\u88cf\u9762\u53f3\u5074\u306eJ2\u30b3\u30cd\u30af\u30bf\u304b\u3089\u3001\u6db2\u6676\u8868\u793a\u3068\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u306b\u7528\u3044\u308bSPI\u63a5\u7d9a\u7528\u306e\u4fe1\u53f7\u304c\u3067\u3066\u3044\u308b\u3002\u5236\u5fa1\u7528\u306eIC\u306f\u3001\u6db2\u6676\u304c<strong>ILI9341<\/strong>\u3067\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u304c<strong>HR2046<\/strong>(TI\u306e<strong>TSC2046<\/strong>\u4e92\u63db)\u306e\u3088\u3046\u3067\u3042\u308b\u3002\u88cf\u9762\u306b\u306fSD\u30ab\u30fc\u30c9\u30b9\u30ed\u30c3\u30c8\u3082\u3064\u3044\u3066\u3044\u308b\u304c\u3001\u4eca\u56de\u306f\u4f7f\u308f\u306a\u3044\u3002<\/p>\n<p>\u5404\u5236\u5fa1\u7528IC\u306e\u30c7\u30fc\u30bf\u30b7\u30fc\u30c8\u306f\u4ee5\u4e0b\u304b\u3089\u5165\u624b\u3057\u305f\u3002<\/p>\n<ul>\n<li>ILI9341 (<a href=\"https:\/\/cdn-shop.adafruit.com\/datasheets\/ILI9341.pdf\">https:\/\/cdn-shop.adafruit.com\/datasheets\/ILI9341.pdf<\/a>)<\/li>\n<li>TSC2046 (<a href=\"http:\/\/www.tij.co.jp\/jp\/lit\/ds\/symlink\/tsc2046.pdf\">http:\/\/www.tij.co.jp\/jp\/lit\/ds\/symlink\/tsc2046.pdf<\/a> )<\/li>\n<\/ul>\n<p>\u6db2\u6676\u3078\u306e\u63cf\u753b\u7528\u306b\u306fAdafruit\u793e\u306e\u30e9\u30a4\u30d6\u30e9\u30ea ( <a href=\"https:\/\/github.com\/adafruit\/Adafruit_ILI9341\">Adafruit_ILI9341<\/a> \u304a\u3088\u3073\u00a0<a href=\"https:\/\/github.com\/adafruit\/Adafruit-GFX-Library\">Adafruit_GFX<\/a>) \u3092\u7528\u3044\u305f (\u30ea\u30f3\u30af\u5148\u306f\u3044\u305a\u308c\u3082GitHub)\u3002<\/p>\n<p>PRO MINI\u3068\u306e\u63a5\u7d9a\u306fSPI\u306a\u306e\u3067\u3001MISO, MOSI, SCK, SS\u304c\u5fc5\u9808\u306b\u306a\u308b\u3002\u3053\u308c\u30894\u672c\u306b\u52a0\u3048\u3066\u3001D\/C (Data or Command)\u3068RESET\u306e2\u672c\u304c\u5fc5\u8981\u3002\u3055\u3089\u306b\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u7528\u306eLED\u7aef\u5b50\u3092\u96fb\u6e90\u306b\u63a5\u7d9a\u3059\u308b(\u5f8c\u8ff0\u3059\u308b\u304c\u3001\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u306f\u30b9\u30b1\u30c3\u30c1\u304b\u3089\u6d88\u706f\/\u70b9\u706f\u3067\u304d\u308b\u3088\u3046\u306a\u56de\u8def\u3068\u3057\u305f)\u3002<\/p>\n<p>\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u5074\u3082SPI\u306e\u305f\u3081\u3001MISO, MOSI, SCK\u306f\u6db2\u6676\u5074\u3068\u5171\u901a\u3068\u3057\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u3092\u9078\u629e\u3059\u308b\u305f\u3081\u306eSS(Slave Select) \u4fe1\u53f7\u3092TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u306f\u5225\u306eI\/O\u7aef\u5b50\u306b\u63a5\u7d9a\u3059\u308b\u3002\u305d\u3057\u3066\u3001\u30bf\u30c3\u30c1\u3055\u308c\u305f\u3053\u3068\u306e\u691c\u51fa\u7528\u306b\u3001TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u5074\u306eT_IRQ\u3092PRO MINI\u306e\u5272\u8fbc\u307f0\u7aef\u5b50(D2)\u306b\u63a5\u7d9a\u3057\u305f\u3002<\/p>\n<p>\u3057\u305f\u304c\u3063\u3066\u3001PRO MINI\u5074\u306e8\u3064(\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u5236\u5fa1\u3092\u52a0\u3048\u308b\u30689\u3064)\u306eI\/O\u7aef\u5b50\u3092\u4f7f\u3046\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<h2>\u57fa\u672c\u56de\u8def\u56f3<\/h2>\n<p>\u307e\u305a\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u56de\u8def\u69cb\u6210\u3067\u30d6\u30ec\u30c3\u30c9\u30dc\u30fc\u30c9\u4e0a\u306b\u8a66\u4f5c\u3057\u3001TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u305f\u3002<\/p>\n<figure id=\"attachment_6564\" aria-describedby=\"caption-attachment-6564\" style=\"width: 552px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/10\/A_PRO_MINI_IL9341_TFT1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-6564\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/10\/A_PRO_MINI_IL9341_TFT1-552x460.png\" alt=\"\" width=\"552\" height=\"460\" \/><\/a><figcaption id=\"caption-attachment-6564\" class=\"wp-caption-text\">A_PRO_MINI_ILI9341_TFT1<\/figcaption><\/figure>\n<figure id=\"attachment_6580\" aria-describedby=\"caption-attachment-6580\" style=\"width: 414px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/10\/c763a9bd1c6b6b76e9dd23838fcecd24.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-6580\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/10\/c763a9bd1c6b6b76e9dd23838fcecd24-414x552.jpg\" alt=\"A_PRO_MINI_ILI9341_TFT1\" width=\"414\" height=\"552\" \/><\/a><figcaption id=\"caption-attachment-6580\" class=\"wp-caption-text\">A_PRO_MINI_ILI9341_TFT1<\/figcaption><\/figure>\n<p>\u30d6\u30ec\u30c3\u30c9\u30dc\u30fc\u30c9\u306e\u4e0a\u306b\u7d44\u3093\u3060\u3068\u3053\u308d\u3002TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30b3\u30cd\u30af\u30bf\u306e\u90fd\u5408\u3067\u3053\u3093\u306a\u59ff\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u3002\u5de6\u5074\u306e\u96fb\u6e90\u30e2\u30b8\u30e5\u30fc\u30eb\u304b\u30893.0V\u3092\u4e0e\u3048\u3066\u3044\u308b\u3002Arudino PRO MINI\u306f\u3001\u79cb\u6708\u96fb\u5b50\u306e\u30b7\u30ea\u30a2\u30ebUSB\u5909\u63db\u30a2\u30c0\u30d7\u30bf AE-FT231X\u3092\u4ecb\u3057\u3066PC\u306b\u63a5\u7d9a\u3057\u3066\u3044\u308b\u3002<\/p>\n<h3>PRO MINI\u5074\u306eI\/O\u30dd\u30fc\u30c8\u306b\u3064\u3044\u3066<\/h3>\n<p>PRO MINI\u306e\u5404\u30dd\u30fc\u30c8\u3068TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u63a5\u7d9a\u3057\u3066\u3044\u308b\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<th style=\"text-align: center;\" colspan=\"3\">ILI9341(TFTLCD\u7528)<\/th>\n<\/tr>\n<tr>\n<td>D4<\/td>\n<td>LED<br \/>\n(\u56de\u8def\u7d4c\u7531)<\/td>\n<td>LOW\u306e\u3068\u304d\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u3092\u30aa\u30d5\u3001HIGH\u306e\u3068\u304d\u30aa\u30f3<\/td>\n<\/tr>\n<tr>\n<td>D5<\/td>\n<td>CS<\/td>\n<td>ILI9341\u3092SPI\u306e\u901a\u4fe1\u76f8\u624b\u3068\u3057\u3066\u9078\u629e\u3059\u308b\u3068\u304dLOW\u3068\u3059\u308b<\/td>\n<\/tr>\n<tr>\n<td>D6<\/td>\n<td>RST<\/td>\n<td>ILI9341\u3092\u30ea\u30bb\u30c3\u30c8\u3059\u308b<\/td>\n<\/tr>\n<tr>\n<td>D7<\/td>\n<td>D\/C<\/td>\n<td>HIGH\u306e\u3068\u304d\u30c7\u30fc\u30bf\u3001LOW\u306e\u3068\u304d\u30b3\u30de\u30f3\u30c9\u306e\u9001\u4fe1\u3092\u793a\u3059<\/td>\n<\/tr>\n<tr>\n<td>MOSI(D11)<\/td>\n<td>MOSI<\/td>\n<td>SPI Master Out Slave In<\/td>\n<\/tr>\n<tr>\n<td>MISO(D12)<\/td>\n<td>MISO<\/td>\n<td>SPI Master In Slave Out<\/td>\n<\/tr>\n<tr>\n<td>SCK(D13)<\/td>\n<td>SCK<\/td>\n<td>SPI\u30af\u30ed\u30c3\u30af<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: center;\" colspan=\"3\">HR2046(\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u7528)<\/th>\n<\/tr>\n<tr>\n<td>INT0 (D2)<\/td>\n<td>T_IRQ<\/td>\n<td>\u30bf\u30c3\u30c1\u3092\u691c\u51fa\u3057\u305f\u3068\u304dLOW\u3068\u306a\u308b\u3002<\/td>\n<\/tr>\n<tr>\n<td>D8<\/td>\n<td>T_CS<\/td>\n<td>HR2046\u3092SPI\u306e\u901a\u4fe1\u76f8\u624b\u3068\u3057\u3066\u9078\u629e\u3059\u308b\u3068\u304d\u3001LOW\u3068\u3059\u308b<\/td>\n<\/tr>\n<tr>\n<td>MOSI(D11)<\/td>\n<td>T_DIN(MOSI)<\/td>\n<td>SPI Master Out Slave In (\u5171\u901a)<\/td>\n<\/tr>\n<tr>\n<td>MISO(D12)<\/td>\n<td>T_DO(MISO)<\/td>\n<td>SPI Master In Slave Out (\u5171\u901a)<\/td>\n<\/tr>\n<tr>\n<td>SCK(D13)<\/td>\n<td>T_CLK<\/td>\n<td>SPI\u30af\u30ed\u30c3\u30af (\u5171\u901a)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u5236\u5fa1\u56de\u8def<\/h3>\n<p>VCC=+3.3V\u306e\u3068\u304d\u3001TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u306eLED\u7aef\u5b50\u3092VCC\u306b\u63a5\u7d9a\u3057\u3001\u3053\u306e\u30e9\u30a4\u30f3\u3092\u6d41\u308c\u308b\u96fb\u6d41\u3092\u6e2c\u3063\u3066\u307f\u308b\u3068\u7d0448mA\u3060\u3063\u305f(VCC=+3.0V\u306e\u5834\u5408\u306f\u7d0430mA)\u3002\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u3092\u70b9\u3051\u305f\u307e\u307e\u3067\u306f\u4e00\u6669\u3067\u96fb\u6c60\u304c\u3042\u304c\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u30c8\u30e9\u30f3\u30b8\u30b9\u30bf\u3092\u7d44\u5408\u305b\u305f\u30b9\u30a4\u30c3\u30c1\u30f3\u30b0\u56de\u8def\u3067\u30aa\u30f3\uff0f\u30aa\u30d5\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3002<br \/>\n\u3053\u306e\u56de\u8def\u306e\u3088\u3046\u306b\u3001\u8ca0\u8377\u5074\u306b\u6d41\u3059\u96fb\u6d41\u3092\u5236\u5fa1\u3059\u308b\u3068\u304d\u306b\u306fPNP\u30c8\u30e9\u30f3\u30b8\u30b9\u30bf\u3092\u4f7f\u3046\u306e\u304c\u5b9a\u756a\u3067\u3001\u306a\u304a\u304b\u3064PNP\u30c8\u30e9\u30f3\u30b8\u30b9\u30bf\u306e\u30d9\u30fc\u30b9\u3092\u3001\u30a8\u30df\u30c3\u30bf\u63a5\u5730\u3057\u305fNPN\u30c8\u30e9\u30f3\u30b8\u30b9\u30bf\u306e\u30b3\u30ec\u30af\u30bf\u306b\u63a5\u7d9a\u3057\u3066\u304a\u304f\u3053\u3068\u3067\u3001PNP\u306e\u30d9\u30fc\u30b9\u304b\u3089NPN\u306e\u30b3\u30ec\u30af\u30bf\u306b\u6d41\u308c\u308b\u96fb\u6d41\u3092\u30aa\u30f3\uff0f\u30aa\u30d5\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304a\u304f\u3002PNP\u306e\u30d9\u30fc\u30b9\u304b\u3089\u96fb\u6d41\u304c\u6d41\u308c\u306a\u3051\u308c\u3070\u3001\u8ca0\u8377\u5074\u306b\u3082\u96fb\u6d41\u306f\u6d41\u308c\u306a\u3044\u3002<\/p>\n<p>VCC=+3.0V\u3067\u3001TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u5074(\u8868\u793a\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb)\u3082\u30de\u30a4\u30b3\u30f3\u5074\u3082\u554f\u984c\u306a\u3055\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001\u7701\u96fb\u529b\u306e\u305f\u3081\u306b\u96fb\u6e90\u96fb\u5727\u306f+3.0V\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u305f\u3002\u306a\u304a\u3001PRO MINI\u306eBOD FUSE\u306f\u5909\u66f4\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u96fb\u6e90\u96fb\u5727\u304c2.7V\u672a\u6e80\u306b\u306a\u308b\u3068\u30ea\u30bb\u30c3\u30c8\u304c\u304b\u304b\u308b\u3060\u308d\u3046\u3002<\/p>\n<p>\u30c8\u30e9\u30f3\u30b8\u30b9\u30bf\u306e\u30d9\u30fc\u30b9\u62b5\u6297R1\u306f\u30012SA1015\u306e\u30d9\u30fc\u30b9\u96fb\u6d41\u30921mA\u3068\u3059\u308b\u305f\u3081\u306b2.2K\u03a9\u3068\u3057\u3001R2\u306f2SC1815\u306e\u30d9\u30fc\u30b9\u96fb\u6d41\u30920.5mA\u3068\u3059\u308b\u305f\u3081\u306b4.7K\u03a9\u3068\u3057\u305f\u3002PNP\u306e\u30a8\u30df\u30c3\u30bf-\u30b3\u30ec\u30af\u30bf\u9593\u306b\u306f\u3001\u8ca0\u8377(\u6db2\u6676\u306e\u30d0\u30c3\u30af\u30e9\u30a4\u30c8)\u304c\u6c7a\u307e\u3063\u3066\u3044\u308b\u306e\u306730mA\u4ee5\u4e0a\u306e\u96fb\u6d41\u304c\u6d41\u308c\u308b\u3053\u3068\u306f\u306a\u3044\u3002\u5404\u30c8\u30e9\u30f3\u30b8\u30b9\u30bf\u306e\u30b3\u30ec\u30af\u30bf-\u30a8\u30df\u30c3\u30bf\u9593\u306b\u751f\u3058\u308b\u96fb\u4f4d\u5dee(V<small>CE<\/small>)\u3092\u5c0f\u3055\u304f\u3059\u308b\u305f\u3081\u3001\u8a08\u7b97\u5024\u3082\u3088\u308a\u5927\u304d\u306a\u30d9\u30fc\u30b9\u96fb\u6d41\u3092\u4e0e\u3048\u305f\u3002<br \/>\n\u4eca\u56de\u306e\u30b9\u30a4\u30c3\u30c1\u30f3\u30b0\u56de\u8def\u3067\u3082\u3001\u30d9\u30fc\u30b9-\u30a8\u30df\u30c3\u30bf\u9593\u306e\u62b5\u6297(R<small>BE<\/small>)\u3092\u7701\u7565\u3057\u305f\u304cPRO MINI\u306eD4\u3092 digitalWrite(4, LOW); \u3068\u3057\u3066\u3084\u308c\u3070\u3001\u307e\u305a\u5f71\u97ff\u306f\u306a\u3044\u3002\u96fb\u6e90\u6295\u5165\u76f4\u5f8c\u306e\u672a\u521d\u671f\u5316\u6642\u306b\u8ca0\u8377\u5074\u306b\u4e00\u5207\u306e\u96fb\u6d41\u3092\u6d41\u305b\u306a\u3044(\u30ea\u30ec\u30fc\u3092\u63a5\u7d9a\u3059\u308b\u3088\u3046\u306a)\u5834\u5408\u306f\u3001R<small>BE<\/small>\u306b\u3088\u3063\u3066I<small>CBO<\/small>\u306e\u5f71\u97ff\u3092\u6392\u9664\u3057\u305f\u307b\u3046\u304c\u3088\u3044\u3068\u601d\u3046\u3002<\/p>\n<p>\u305d\u3046\u3044\u3048\u3070\u3001LED\u7aef\u5b50\u306b\u4e0e\u3048\u308b\u96fb\u6d41\u3092PWM\u5236\u5fa1\u3067\u3082\u3063\u3066\u7d5e\u3063\u3066\u3084\u308c\u3070\u3001\u30b9\u30b1\u30c3\u30c1\u3067\u660e\u308b\u3055\u3082\u8abf\u6574\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/p>\n<h1>\u30b9\u30b1\u30c3\u30c1<\/h1>\n<p>\u5168\u4f53\u3068\u3057\u3066\u306f\u3001\u3061\u3087\u3063\u3068\u524d\u306b\u4f5c\u3063\u305f\u30b7\u30e3\u30ef\u30fc\u30c8\u30a4\u30ec\u7528\u30ea\u30e2\u30b3\u30f3\u3068\u540c\u3058\u3088\u3046\u306a\u69cb\u9020\u306b\u306a\u308b\u4e88\u5b9a\u3002\u30bf\u30af\u30c8\u30b9\u30a4\u30c3\u30c1\u306e\u30aa\u30f3\u64cd\u4f5c\u3067\u306f\u306a\u304f\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u3078\u306e\u62bc\u5727\u304c\u3001\u30b9\u30ea\u30fc\u30d7\u3092\u89e3\u9664\u3057\u3064\u3064\u30bf\u30c3\u30c1\u4f4d\u7f6e\u3092\u5224\u5b9a\u3059\u308b\u305f\u3081\u306e\u304d\u3063\u304b\u3051(\u5272\u8fbc\u307f)\u306b\u306a\u308b\u3002\u3042\u3068\u306f\u6db2\u6676\u306b\u30dc\u30bf\u30f3\u72b6\u306e\u77e9\u5f62\u3092\u63cf\u753b\u3057\u3066\u3084\u308a\u3001\u30bf\u30c3\u30c1\u3055\u308c\u305f\u77e9\u5f62\u3092\u8b58\u5225\u3057\u3066\u8d64\u5916\u7dda\u3092\u767a\u5c04\u3059\u308c\u3070\u3088\u3044\u3060\u308d\u3046\u3002<\/p>\n<p>\u6db2\u6676\u8868\u793a\u306b\u3064\u3044\u3066\u306fAdafruit\u793e\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u304a\u304b\u3052\u3067\u307b\u3068\u3093\u3069\u4f55\u3082\u8003\u3048\u305a\u306b\u6587\u5b57\u3082\u56f3\u5f62\u3082\u8868\u793a\u3067\u304d\u305f\u306e\u3060\u304c\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u306b\u3064\u3044\u3066\u306f\u306a\u304b\u306a\u304b\u30d4\u30f3\u3068\u304f\u308b\u3082\u306e\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u81ea\u524d\u3067\u7528\u610f\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u7528\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u610f\u56f3\u3057\u305f\u3068\u304a\u308a\u306b\u52d5\u304f\u3053\u3068\u306e\u78ba\u8a8d\u7528\u306e\u30b9\u30b1\u30c3\u30c1\u3092\u63b2\u8f09\u3059\u308b\u3002<\/p>\n<h2>tsc2046_spi.h<\/h2>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092 tsc2046_spi.h \u3068\u3044\u3046\u540d\u524d\u3067\u4fdd\u5b58\u3057\u3001\u30b9\u30b1\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u3068\u540c\u3058\u30d5\u30a9\u30eb\u30c0\u306b\u7f6e\u304f\u3053\u3068\u3067\u30b9\u30b1\u30c3\u30c1\u306b\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u304b\u3089\u306e\u8aad\u307f\u53d6\u308a\u6a5f\u80fd\u3092\u8ffd\u52a0\u3057\u305f\u3002<\/p>\n<pre class=\"height-set:true nums:true lang:c++ decode:true \" title=\"tsc2046_spi.h\">#include &lt;SPI.h&gt;\r\ntypedef bool (*TouchtHandler_t)(int x, int y) ;\r\nclass tsc2046_spi {\r\n  uint8_t pin_cs;\r\n  uint16_t tft_width;\r\n  uint16_t tft_height;\r\n  uint8_t tft_rotation;\r\n  int rx, ry, rz; \/\/ raw data.\r\n  TouchtHandler_t touch_handler;\r\n\r\npublic:\r\n  tsc2046_spi(uint8_t cs, uint16_t width = 240, uint16_t height = 320, uint8_t rotation = 1) {\r\n    touch_handler = 0;\r\n    pin_cs = cs;\r\n    pinMode(pin_cs, OUTPUT);\r\n    digitalWrite(pin_cs, HIGH);\r\n    tft_width = width;\r\n    tft_height = height;\r\n    tft_rotation = rotation;\r\n    SPI.begin();\r\n    read_adc(true);\r\n  }\r\n\r\n  void setHandler(TouchtHandler_t h) {\r\n    touch_handler = h;\r\n  }\r\n\/\/  xyz\u304a\u306e\u304a\u306e\u306eA\/D\u5909\u63db\u306e\u5b9f\u884c\u3068\u5024\u306e\u8aad\u307f\u51fa\u3057\u3002\r\n  void read_adc(bool pd_only = false) {\r\n    SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));\r\n    digitalWrite(pin_cs, LOW);\r\n    if (pd_only) {  \/\/ force power-down mode.\r\n      SPI.transfer16(B11010000); \/\/ get Y and request Power down.\r\n      SPI.transfer16(0);    \/\/ dummy read.\r\n      digitalWrite(pin_cs, HIGH); \/\/ \r\n      SPI.endTransaction();\r\n      return;\r\n    } else {\r\n      int  z1 = 0;   \/\/ 011B\r\n      int  z2 = 0;   \/\/ 100B\r\n      rz = 0;\r\n      rx = 0;\r\n      ry = 0;\r\n      SPI.transfer(B10110011);  \/\/ request Z1\r\n      for(int i = 0; i &lt; 4; i++) {  \/\/ 4\u56de\u8aad\u3093\u3067\u5e73\u5747\u5024\u3092\u6c42\u3081\u308b\u3002\r\n        z1 += SPI.transfer16(B11000011) &gt;&gt; 3;  \/\/ get Z1 and request Z2\r\n        z2 += SPI.transfer16(B11010011) &gt;&gt; 3;  \/\/ get Z2 and request X\r\n        rx += SPI.transfer16(B10010011) &gt;&gt; 3;  \/\/ get X and request Y\r\n        ry += SPI.transfer16(B10110011) &gt;&gt; 3;  \/\/ get Y and request Z1.\r\n      }\r\n      SPI.transfer16(B11010000); \/\/request Power down.\r\n      SPI.transfer16(0);    \/\/ dummy read.\r\n      digitalWrite(pin_cs, HIGH); \/\/ CS==LOW\u306e\u671f\u9593\u306f,\u7d04274\u03bcs (@8MHz)\r\n      SPI.endTransaction();\r\n      z1 &gt;&gt;= 2, z2 &gt;&gt;= 2, rx &gt;&gt;= 2, ry &gt;&gt;= 2;\r\n      \/\/ \u5f37\u304f\u62bc\u3059\u307b\u3069\u62b5\u6297\u5024(\u8aad\u307f\u53d6\u308a\u5024)\u306f\u5c0f\u3055\u304f\u306a\u308b\u3002rx\u5024\u3067\u88dc\u6b63\u3057\u3066\u6700\u5927\u5024\u304b\u3089\u5f15\u304f\u3002\r\n      if (z1 &gt; 0 &amp;&amp; z2 &gt; 0) \r\n        rz = 4096 - (int)((double)(z2 \/ z1 * rx \/ 4.0 ));\r\n      else\r\n        rz = 0;\r\n    }\r\n  }\r\n\/\/ \u30bf\u30c3\u30c1\u53ef\u80fd\u9818\u57df\u3002\r\n\/\/ \u5b9f\u969b\u306b\u30bf\u30c3\u30c1\u3057\u3066\u5f97\u305f\u5024\u3002\u5ea7\u6a19\u306f raw value (rx, ry)\u304b\u3089\u5f97\u3066\u3044\u308b\u3002\r\nenum { tsc_min_x = 280, tsc_min_y = 150, tsc_max_x = 4000, tsc_max_y = 3700 };\r\n \r\n  const bool read_pos(int&amp; x, int&amp; y) {\r\n    read_adc();\r\n    if (rz &lt; 800)\r\n      return false;\r\n    if (tft_rotation &amp; 1) {\r\n      y = map(rx,  tsc_min_x, tsc_max_x, 0, tft_width);\r\n      x = map(ry,  tsc_min_y, tsc_max_y, 0, tft_height);\r\n      if (tft_rotation == 3) {  \/\/ J2\u7aef\u5b50\u5074\u3092\u5de6\u306b\u898b\u305f\u3068\u304d\u5de6\u4e0a\u304c\u30011: (319, 239) or 3 : (0, 0)\u3002\r\n        x = tft_height - x;\r\n        y = tft_width - y;\r\n      }\r\n    }\r\n    return (x &gt;= 0 &amp;&amp; y &gt;= 0);\r\n  }\r\n\r\n  void read_pos_raw(int&amp; x, int&amp; y, int&amp; z) {\r\n    x = rx;\r\n    y = ry;\r\n    z = rz;\r\n  }\r\n\r\n  enum { LOOP_DELAY = 40, TOUCH_LOOP_LIMIT = 1500, UNTOUCH_LIMIT = 500 };\r\n  void touch_loop() {\r\n    int16_t limit_count = 0;\r\n    int16_t penoff_count = 0;\r\n    bool penoff = false;\r\n    while(limit_count &lt; TOUCH_LOOP_LIMIT \/ LOOP_DELAY) {\r\n      int x, y;\r\n      if (!read_pos(x, y)) {\r\n        if (penoff &amp;&amp; penoff_count &gt; UNTOUCH_LIMIT \/ LOOP_DELAY)\r\n          return;\r\n        if (!penoff) {\r\n          penoff = true;\r\n          penoff_count = 0;\r\n        }\r\n        if (touch_handler)\r\n          touch_handler(-1, -1); \r\n      } else {    \r\n        penoff = false;\r\n        penoff_count = 0;\r\n        if (touch_handler)\r\n          if (touch_handler(x, y)) {\r\n            delay(LOOP_DELAY);  \r\n            continue;\r\n          }\r\n     }\r\n     delay(LOOP_DELAY);\r\n     penoff_count++;\r\n     limit_count++;\r\n    }\r\n    touch_handler(-1, -1);\r\n  } \r\n};<\/pre>\n<p>TSC2046 \u306f\u62b5\u6297\u6027\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u306e\u5236\u5fa1\u7528\u30c7\u30d0\u30a4\u30b9\u3067\u3001\u9010\u6b21\u6bd4\u8f03\u578b\u306eA\/D\u30b3\u30f3\u30d0\u30fc\u30bf\u304a\u3088\u3073\u30de\u30eb\u30c1\u30d7\u30ec\u30af\u30b5\u3092\u5185\u8535\u3057\u3066\u3044\u308b\u3002\u30de\u30a4\u30b3\u30f3\u5074\u304b\u3089SPI\u3092\u7d4c\u7531\u3057\u3066\u6e2c\u5b9a\u5bfe\u8c61\u3068\u6e2c\u5b9a\u65b9\u5f0f\u304a\u3088\u3073\u52d5\u4f5c\u3092\u6307\u5b9a\u3059\u308b8\u30d3\u30c3\u30c8\u306e\u30b3\u30de\u30f3\u30c9\u30d0\u30a4\u30c8\u3092\u9001\u4fe1\u3057\u3001\u6b21\u306e16\u30af\u30ed\u30c3\u30af\u3067\u6e2c\u5b9a\u7d50\u679c\u3092\u5f97\u308b\u3002\u30b3\u30de\u30f3\u30c9\u30d0\u30a4\u30c8\u9001\u4fe1\u6642\u306e5\u756a\u76ee\u306e\u30af\u30ed\u30c3\u30af\u306e\u7acb\u4e0b\u308a\u3067\u62b5\u6297\u5024\u304c\u30db\u30fc\u30eb\u30c9\u3055\u308c\u30018\u756a\u76ee\u306e\u30af\u30ed\u30c3\u30af\u306e\u7acb\u4e0b\u308a\u304b\u3089A\/D\u5909\u63db\u304c\u958b\u59cb\u3059\u308b\u3002\u305d\u3057\u3066\u3001\u6b21\u306e\u30af\u30ed\u30c3\u30af\u306e\u7acb\u4e0b\u308a\u304b\u3089\u5909\u63db\u7d50\u679c\u304c\u9001\u4fe1\u3055\u308c\u3066\u304f\u308b(MSB\u304c\u5148\u982d)\u3002\u30b3\u30de\u30f3\u30c9\u30d0\u30a4\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u69cb\u6210\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<th style=\"text-align: center;\" colspan=\"3\">\u5236\u5fa1\u30d0\u30a4\u30c8\u306e\u69cb\u6210<\/th>\n<\/tr>\n<tr>\n<th>\u540d\u79f0<\/th>\n<th>\u30d3\u30c3\u30c8<\/th>\n<th>\u8aac\u660e<\/th>\n<\/tr>\n<tr>\n<td>\u30b9\u30bf\u30fc\u30c8\u30d3\u30c3\u30c8<\/td>\n<td>bit7 (MSB)<\/td>\n<td>\u5236\u5fa1\u30d0\u30a4\u30c8\u306e\u958b\u59cb\u3092\u793a\u3059\u3002\u5e38\u306b1<\/td>\n<\/tr>\n<tr>\n<td>\u6e2c\u5b9a\u5bfe\u8c61<\/td>\n<td>bit6\uff5e4<\/td>\n<td>\u30de\u30eb\u30c1\u30d7\u30ec\u30af\u30b5\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u5b9a\u3002<br \/>\n001b : Y\u4f4d\u7f6e<br \/>\n101b : X\u4f4d\u7f6e<br \/>\n011b : Z1\u4f4d\u7f6e<br \/>\n100b : Z2\u4f4d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>\u5909\u63db\u30e2\u30fc\u30c9<\/td>\n<td>bit3<\/td>\n<td>A\/D\u5909\u63db\u306e\u5206\u89e3\u80fd\u6307\u5b9a\u30020\u306e\u3068\u304d12\u30d3\u30c3\u30c8\u30011\u306e\u3068\u304d8\u30d3\u30c3\u30c8<\/td>\n<\/tr>\n<tr>\n<td>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u96fb\u5727\u30e2\u30fc\u30c9\u306e\u6307\u5b9a<\/td>\n<td>bit2<\/td>\n<td>\u30bf\u30c3\u30c1\u4f4d\u7f6e\u6e2c\u5b9a\u6642\u306b\u306f\u30010\u306e\u5dee\u52d5\u30e2\u30fc\u30c9\u3092\u9078\u629e\u30021\u306e\u3068\u304d\u306f\u5358\u30a8\u30f3\u30c9\u30e2\u30fc\u30c9\u3068\u306a\u308b<\/td>\n<\/tr>\n<tr>\n<td>\u30d1\u30ef\u30fc\u30c0\u30a6\u30f3\u30e2\u30fc\u30c9\u30d3\u30c3\u30c8<\/td>\n<td>bit1\uff5e0<\/td>\n<td>\u30bf\u30c3\u30c1\u4f4d\u7f6e\u306e\u8aad\u307f\u53d6\u308a\u6642\u306f11b\u3068\u3057\u3001\u8aad\u307f\u53d6\u308a\u7d42\u4e86\u6642\u306b\u306f00b\u3068\u3059\u308b\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u00a0\u5404\u90e8\u306e\u8aac\u660e<\/h2>\n<h6>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf<\/h6>\n<p>\u30e1\u30a4\u30f3\u306e\u30b9\u30b1\u30c3\u30c1\u304b\u3089\u3001\u30b9\u30ec\u30fc\u30d6\u30bb\u30ec\u30af\u30c8\u7528\u306eI\/O\u30dd\u30fc\u30c8\u756a\u53f7\u3001TFT\u6db2\u6676\u306e\u5e45\u304a\u3088\u3073\u9ad8\u3055\u3001TFT\u6db2\u6676\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u540c\u3058\u5ea7\u6a19\u56de\u8ee2\u65b9\u5411(\u3069\u306e\u9685\u3092 0,0 \u3068\u3059\u308b\u304b\u3001\u9577\u624b\u65b9\u5411\u3092X\u3068\u3059\u308b\u304bY\u3068\u3059\u308b\u304b)\u3092\u4e0e\u3048\u3066\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3059\u308b\u3002TFT\u6db2\u6676\u306e\u60c5\u5831\u304c\u5fc5\u8981\u306a\u306e\u304b\u306f\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u304b\u3089\u5f97\u3089\u308c\u305f\u5ea7\u6a19\u60c5\u5831\u3092TFT\u6db2\u6676\u306e\u8868\u793a\u5ea7\u6a19\u7cfb\u3068\u5408\u308f\u305b\u308b\u305f\u3081\u3067\u3042\u308b\u3002<\/p>\n<p>\u306a\u304a\u3001\u753b\u9762\u3084\u30d1\u30cd\u30eb\u306e\u56de\u8ee2\u306b\u3064\u3044\u3066\u306f\u30011\u30683\u306e\u307f\u306b\u5bfe\u5fdc\u3057\u3066\u304a\u308a\u3001\u5e38\u306b\u9577\u624b\u65b9\u5411\u3092x\u3068\u3057\u3066\u3044\u308b\u3002<\/p>\n<h6>void read_adc(bool pd_only = false) ;<\/h6>\n<p>TSC2046\u3092\u9078\u629e\u3057\u3066SPI\u3067\u901a\u4fe1\u3092\u884c\u3044\u3001\u30bf\u30c3\u30c1\u4f4d\u7f6e\u306e\u691c\u51fa\u3092\u884c\u3046\u3002pd_only = true \u3068\u3057\u305f\u5834\u5408\u3001\u8aad\u307f\u53d6\u308a\u306f\u884c\u308f\u305a\u3001\u30d1\u30ef\u30fc\u30c0\u30a6\u30f3\u30e2\u30fc\u30c9\u30d3\u30c3\u30c8\u3068\u3057\u3066 00b\u3092\u6307\u5b9a\u3057\u3001\u30d1\u30ef\u30fc\u30c0\u30a6\u30f3\u3059\u308b\u3068\u5171\u306b\u30bf\u30c3\u30c1\u306b\u3088\u308b\u5272\u8fbc\u307f\u52d5\u4f5c(\u30bf\u30c3\u30c1\u3055\u308c\u308b\u3068T_IRQ\u304c&#8221;L&#8221;\u3068\u306a\u308b\u52d5\u4f5c)\u3092\u8a31\u53ef\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>A\/D\u5909\u63db\u7d50\u679c\u306f12\u30d3\u30c3\u30c8\u306a\u306e\u306b\u3001<span class=\"lang:default decode:true crayon-inline\">z1 += SPI.transfer16(B11000011) &gt;&gt; 3;<\/span>\u00a0 \u306e\u3088\u3046\u306b3\u56de\u3057\u304b\u30b7\u30d5\u30c8\u3057\u3066\u304a\u3089\u305a\u3001\u307e\u308b\u306713\u30d3\u30c3\u30c8\u306e\u30c7\u30fc\u30bf\u3092\u5f97\u3066\u3044\u308b\u3088\u3046\u306b\u898b\u3048\u308b\u304c\u3001\u3053\u308c\u306f\u5909\u63db\u7d50\u679c\u306e\u6700\u521d\u306e\u30d3\u30c3\u30c8( MSB = \u30d3\u30c3\u30c811)\u304c\u51fa\u3066\u304f\u308b\u306e\u304c9\u756a\u76ee\u306e\u30af\u30ed\u30c3\u30af\u306e\u7acb\u4e0b\u308a\u30a8\u30c3\u30b8\u3067\u3042\u308b\u305f\u3081(\u30b3\u30de\u30f3\u30c9\u30d0\u30a4\u30c8\u306e\u30b9\u30bf\u30fc\u30c8\u30d3\u30c3\u30c8\u6642\u306b1\u756a\u76ee\u306e\u30af\u30ed\u30c3\u30af\u304c\u51fa\u3066\u3044\u308b)\u3002\u3064\u307e\u308a\u3001SPI MODE0\u306a\u306e\u3067\u30de\u30a4\u30b3\u30f3\u5074\u306f\u30af\u30ed\u30c3\u30af\u306e\u7acb\u4e0a\u308a\u30a8\u30c3\u30b8\u306b\u304a\u3044\u3066\u30c7\u30fc\u30bf\u30d3\u30c3\u30c8\u3092\u30e9\u30c3\u30c1\u3059\u308b\u304b\u3089\u3001MSB\u3092\u30e9\u30c3\u30c1\u3067\u304d\u308b\u306e\u306f10\u756a\u76ee\u306e\u30af\u30ed\u30c3\u30af\u306b\u304a\u3044\u3066\u3001\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308b\u3002\u8a00\u3044\u63db\u3048\u308c\u3070\u3001MSB\u304c\u5e38\u306b0\u306e13\u30d3\u30c3\u30c8\u306e\u30c7\u30fc\u30bf\u3092\u5f97\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u3082\u3067\u304d\u308b\u3002\u8a73\u3057\u304f\u306f\u3001TSC2046\u306e\u30c7\u30fc\u30bf\u30b7\u30fc\u30c8\u306b\u3042\u308b\u5909\u63db\u30bf\u30a4\u30df\u30f3\u30b0\u56f3\u3092\u53c2\u7167\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u8aad\u307f\u53d6\u308a\u306f\u3001x,y,z1,z2\u306e\u304a\u306e\u304a\u306e\u306b\u3064\u3044\u30664\u56de\u8aad\u51fa\u3057\u3092\u884c\u3044\u30014\u3067\u5272\u3063\u3066\u5e73\u5747\u5024\u3092\u5f97\u3066\u3044\u308b\u3002TSC2046\u7528\u306e\u30b9\u30ec\u30fc\u30d6\u30bb\u30ec\u30af\u30c8(CS\u7aef\u5b50)\u3092LOW\u306b\u3057\u3066\u3044\u308b\u671f\u9593\u306f\u3001\u30ed\u30b8\u30a2\u30ca\u3067\u898b\u305f\u3068\u3053\u308d274\u03bcsec\u3060\u3063\u305f\u3002\u4eba\u9593\u304c\u64cd\u4f5c\u3059\u308b\u5185\u5bb9\u3092\u5f97\u308b\u3082\u306e\u306a\u306e\u3067\u5341\u5206\u306b\u9ad8\u901f\u3068\u3044\u3048\u308b\u3060\u308d\u3046\u3002<\/p>\n<p>Z\u8ef8\u65b9\u5411(\u62bc\u5727)\u306f\u3001\u30c7\u30fc\u30bf\u30b7\u30fc\u30c8\u306b\u3042\u308b\u5727\u529b\u6e2c\u5b9a\u7528\u306e\u5f0f\u3092\u9069\u5f53\u306a\u30b3\u30fc\u30c9\u3067\u7f6e\u304d\u63db\u3048\u305f\u3082\u306e\u3092\u4f7f\u3063\u3066\u5f97\u3066\u3044\u308b\u3002\u3053\u306e\u3088\u3046\u306a\u8a08\u7b97\u3092\u884c\u308f\u306a\u3044\u3068\u3001\u30bf\u30c3\u30c1\u3057\u305f\u4f4d\u7f6e\u304c\u6db2\u6676\u30d1\u30cd\u30eb\u306e\u4e2d\u592e\u90e8\u304b\u7aef\u5bc4\u308a\u304b\u306b\u3088\u3063\u3066Z1\u3084Z2\u306e\u5024\u3092\u5927\u304d\u304f\u5909\u308f\u3063\u3066\u3057\u307e\u3046\u3002<\/p>\n<h6>\u00a0const bool read_pos(int&amp; x, int&amp; y)<\/h6>\n<p>read_adc() \u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u5f97\u305f\u751f\u30c7\u30fc\u30bf(rx, ry, rz) \u306b\u57fa\u3044\u3066\u3001\u6db2\u6676\u5074\u306e\u5ea7\u6a19\u306b\u5909\u63db\u3057\u3066\u8fd4\u3059\u3002\u306a\u304a\u3001\u62bc\u5727(rz)\u304c\u3042\u308b\u7a0b\u5ea6\u4ee5\u4e0a\u306e\u5927\u304d\u3055\u3067\u306a\u3051\u308c\u3070\u3001\u30bf\u30c3\u30c1\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u898b\u306a\u3057\u3066false\u3092\u8fd4\u3059\u3002<\/p>\n<p>TSC2046\u304c\u8fd4\u3059\u5ea7\u6a19\u5024(rx, ry)\u306f\u3001\u304e\u308a\u304e\u308a\u7aef\u3092\u30bf\u30c3\u30c1\u3057\u3066\u30820\u30844095\u306b\u306f\u306a\u3089\u305a\u3001\u82e5\u5e72\u306e\u30de\u30fc\u30b8\u30f3\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u3088\u3046\u3060\u3002\u305d\u306e\u305f\u3081\u3001\u5b9f\u969b\u306b\u30bf\u30c3\u30c1\u3057\u3066\u5f97\u305f\u7aef\u306e\u5ea7\u6a19\u5024\u3092\u5b9a\u6570\u3068\u3057\u3066\u30b3\u30fc\u30c9\u306b\u66f8\u3044\u3066\u3042\u308b\u3002\u304a\u305d\u3089\u304f\u3001\u88fd\u54c1\u3054\u3068\u306e\u3070\u3089\u3064\u304d\u3082\u3042\u308b\u3060\u308d\u3046\u3002\u305d\u308c\u3089\u306e\u5b9a\u6570\u3068\u3001Arduino \u306e map() \u95a2\u6570\u306b\u3088\u308a\u751f\u5ea7\u6a19\u3092\u6db2\u6676\u5ea7\u6a19\u306b\u5909\u63db\u3057\u3066\u3044\u308b\u3002<\/p>\n<h6>void touch_loop()<\/h6>\n<p>arduino\u306e void loop(); \u304b\u3089\u547c\u3073\u51fa\u3055\u308c\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u3066\u304a\u308a\u3001\u30bf\u30c3\u30c1\u691c\u51fa\u7528\u306e\u30eb\u30fc\u30d7\u3092\u56de\u3059\u3002\u30eb\u30fc\u30d7\u5185\u3067read_pos() \u3092\u547c\u3073\u51fa\u3057\u3001\u5341\u5206\u306a\u62bc\u5727\u3067\u30bf\u30c3\u30c1\u3055\u308c\u3066\u3044\u308b\u306a\u3089\u3070\u3001\u305d\u306e\u5ea7\u6a19\u3092\u95a2\u6570\u30dd\u30a4\u30f3\u30bf\u00a0touch_handler \u306b\u30a2\u30c9\u30ec\u30b9\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u308b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u306b\u6e21\u3059\u3002<\/p>\n<p>\u30bf\u30c3\u30c1\u3055\u308c\u3066\u3044\u306a\u3044\u72b6\u614b\u304c\u4e00\u5b9a\u306e\u671f\u9593\u7d9a\u304f\u304b\u3001\u30eb\u30fc\u30d7\u306e\u4e0a\u9650\u56de\u6570\u306b\u9054\u3057\u305f\u3089\u7d42\u4e86\u3059\u308b\u3002\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u5074\u304c true \u3092\u8fd4\u3057\u305f\u5834\u5408\u3001\u9023\u7d9a\u3057\u305f\u30bf\u30c3\u30c1\u691c\u51fa\u304c\u8a31\u53ef\u3055\u308c\u305f\u3053\u3068\u306b\u306a\u308a\u3001\u30eb\u30fc\u30d7\u306f\u4e0a\u9650\u56de\u6570\u306b\u9054\u3057\u306a\u3044\u3002\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3067\u306eGUI\u30dc\u30bf\u30f3\u306e\u64cd\u4f5c\u5236\u5fa1\u306e\u305f\u3081\u306b\u305d\u306e\u3088\u3046\u306b\u3057\u305f\u3002<\/p>\n<p>\u306a\u304a\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u304c\u51fa\u529b\u3059\u308b\u30c7\u30fc\u30bf\u3092\u691c\u8a3c\u3059\u308b\u5834\u5408\u306f\u30e1\u30a4\u30f3\u30b9\u30b1\u30c3\u30c1\u306e void loop() \u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308c\u3070\u3088\u3044\u3060\u308d\u3046\u3002<\/p>\n<pre class=\"lang:c++ decode:true\">tsc2046_spi TS(8);\r\nvoid loop() {\r\n  delay(20);\r\n  TS.read_adc(); \/\/ \r\n  int x, y, z;\r\n  TS.read_pos_raw(x, y, z);\r\n  char tmp[50];\r\n  sprintf(tmp, \"x=%d,y=%d,z=%d\", x, y, z);\r\n  Serial.println(tmp);  \r\n}<\/pre>\n<p>\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u30b7\u30ea\u30a2\u30eb\u30e2\u30cb\u30bf\u306b20msec\u3054\u3068\u306b\u5909\u63db\u7d50\u679c(\u306e\u5e73\u5747\u5024)\u304c\u8868\u793a\u3055\u308c\u7d9a\u3051\u308b\u3002<\/p>\n<h2>Adafruit_ILI9341.h\u3078\u306e\u8ffd\u52a0\u9805\u76ee<\/h2>\n<p>ILI9341\u81ea\u4f53\u306b\u306f\u3001\u8868\u793a\u306e\u30aa\u30f3\uff0f\u30aa\u30d5\u3084\u30b9\u30ea\u30fc\u30d7\u30e2\u30fc\u30c9\u3092\u958b\u59cb\u3059\u308b\u305f\u3081\u306e\u6a5f\u80fd\u304c\u3042\u308b\u306e\u3060\u304c\u3001\u6b8b\u5ff5\u306a\u304c\u3089\u8868\u8a18\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u306f\u7d44\u307f\u8fbc\u307e\u308c\u3066\u3044\u306a\u3044\u3002\u3061\u3087\u3063\u3068\u305a\u308b\u3044\u6c17\u3082\u3059\u308b\u304c\u4ee5\u4e0b\u306e\u77ed\u3044\u30b3\u30fc\u30c9\u3092 adafruit_ili9341.h \u306e public: \u30bb\u30af\u30b7\u30e7\u30f3\u306b\u8ffd\u52a0\u3057\u305f\u3002<\/p>\n<pre class=\"lang:c++ decode:true\">void tft_wakeup() {\r\n    delay(5);\r\n    startWrite();\r\n    writeCommand(ILI9341_SLPOUT);\r\n    delay(120);\r\n    writeCommand(ILI9341_DISPON);    \/\/Display on\r\n    delay(5);\r\n    endWrite();\r\n}\r\n\r\nvoid tft_sleep() {\r\n    delay(5);\r\n    startWrite();\r\n    writeCommand(ILI9341_DISPOFF);    \/\/Display off\r\n    delay(5);\r\n    writeCommand(ILI9341_SLPIN);\r\n    endWrite();\r\n}<\/pre>\n<p>\u5b9f\u306e\u3068\u3053\u308d\u3001\u901a\u5e38\u306e\u72b6\u614b\u3067tft_sleep() \u3057\u3066\u30826mA\u7a0b\u5ea6(@+3.0V) \u3057\u304b\u7bc0\u7d04\u3067\u304d\u306a\u3044\u3057\u6db2\u6676\u306b\u306f\u4f55\u3082\u8868\u793a\u3055\u308c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u3002\u3042\u307e\u308a\u52b9\u679c\u306f\u306a\u3044\u306e\u304b\u306a\u3068\u601d\u3063\u3066\u3044\u305f\u304c\u3001tft_sleep()\u3068\u30de\u30a4\u30b3\u30f3\u306e\u30b9\u30ea\u30fc\u30d7\u304a\u3088\u3073\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u30aa\u30d5\u3068\u3092\u7d44\u5408\u305b\u308b\u3053\u3068\u3067\u3001\u4eca\u56de\u306e\u56de\u8def\u306b\u6d41\u308c\u308b\u96fb\u6d41\u309220\u03bcA\u7a0b\u5ea6\u307e\u3067\u6e1b\u3089\u3059\u3053\u3068\u304c\u3067\u304d\u305f\u3002\u3053\u308c\u306a\u3089\u96fb\u6c60\u99c6\u52d5\u3067\u4f5c\u3063\u3066\u307f\u3066\u3082\u3044\u3044\u3060\u308d\u3046\u3002<\/p>\n<h2>\u30e1\u30a4\u30f3\u30b9\u30b1\u30c3\u30c1(A_PROMINI_XPT2046.ino)<\/h2>\n<p>\u30e1\u30a4\u30f3\u306e\u30b9\u30b1\u30c3\u30c1\u306b\u306f\u6db2\u6676\u306e\u8868\u793a\u306e\u30aa\u30f3\uff0f\u30aa\u30d5\u3001\u30bf\u30c3\u30c1\u306b\u3088\u308b\u30b9\u30ea\u30fc\u30d7\u72b6\u614b (SLEEP_MODE_PWR_DOWN) \u304b\u3089\u306e\u5fa9\u5e30\u3001\u30bf\u30c3\u30c1\u52d5\u4f5c\u306e\u78ba\u8a8d\u306a\u3069\u3092\u884c\u3046\u305f\u3081\u306e\u30b3\u30fc\u30c9\u3092\u5165\u308c\u305f\u3002PRO MINI\u306e\u7701\u96fb\u529b\u306e\u305f\u3081\u306e\u30b3\u30fc\u30c9\u306a\u3069\u306f\u4ee5\u524d\u3068\u540c\u69d8\u3002<\/p>\n<pre class=\"height-set:true nums:true lang:c++ decode:true \" title=\"A_PROMINI_XPT2046\">#include &lt;avr\/sleep.h&gt;\r\n#include &lt;Adafruit_GFX.h&gt;\r\n#include &lt;Adafruit_ILI9341.h&gt;\r\n\r\n#define TFT_RST 6\r\n#define TFT_DC 7\r\n#define TFT_CS 5\r\n#define LED_PIN 4\r\nAdafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);\r\n#define TFT_ROTATION  3 \/\/ J2\u7aef\u5b50\u5074\u3092\u5de6\u306b\u898b\u305f\u3068\u304d\u5de6\u4e0a\u304c\u30011: (319, 239) or 3 : (0, 0)\u3002\r\n\r\n#include \"tsc2046_spi.h\"\r\ntsc2046_spi TS(8, ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT, TFT_ROTATION);\r\n\r\nvoid getTextMetrics(char* cpText, uint16_t&amp; tw, uint16_t&amp; th) {\r\n  int16_t tx, ty;\r\n  tft.getTextBounds(cpText, 0, 0, &amp;tx, &amp;ty, &amp;tw, &amp;th);\r\n}\r\n\r\nbool onTouch(int x, int y) {\r\n  char tmp[32];\r\n  static uint16_t text_h = 0;\r\n  static uint16_t text_w = 0;\r\n  enum {POS_X = 10, POS_Y = 20 };\r\n\r\n  tft.setTextSize(1);\r\n  tft.setTextColor(ILI9341_BLACK);\r\n  if (text_h == 0) {\r\n    memset(tmp, 'W', sizeof(tmp));\r\n    tmp[sizeof(tmp) - 1] = 0;\r\n    getTextMetrics((char*)tmp, text_w, text_h);\r\n    sprintf(tmp, \"%d,%d,%d,%d\", POS_X, POS_Y, text_w, text_h);\r\n    Serial.println(tmp);\r\n  }\r\n  int rx, ry, rz;\r\n  TS.read_pos_raw(rx, ry, rz);\r\n  tft.fillRect(POS_X, POS_Y, text_w, text_h, ILI9341_WHITE);\r\n  sprintf(tmp, \"x=%d, y=%d, rx=%d, ry=%d\", x, y, rx, ry);\r\n  tft.setCursor(POS_X, POS_Y);\r\n  tft.println(tmp);\r\n  return true;  \/\/ \u9023\u7d9a\u691c\u51fa\u3055\u305b\u308b\u3002\r\n}\r\n\r\nvoid setup() {\r\n  ADCSRA &amp;= 0x7f;  \/\/ ADC\u7981\u6b62\u3002MSB \u3092 0\u306b\u3002\r\n  ACSR |= 0x80;    \/\/ \u30a2\u30ca\u30ed\u30b0\u30b3\u30f3\u30d1\u30ec\u30fc\u30bf\u7981\u6b62\r\n  delay(50);\r\n  Serial.begin(115200);\r\n  pinMode(LED_PIN, OUTPUT);\r\n  digitalWrite(LED_PIN, 0);\r\n  \r\n  pinMode(2, INPUT_PULLUP);\r\n  digitalWrite(TFT_RST, 0);  \r\n  delay(10);\r\n  digitalWrite(TFT_RST, 1);  \r\n  delay(10);\r\n  tft.begin();\r\n  tft.setRotation(TFT_ROTATION);\r\n  tft.fillScreen(ILI9341_WHITE);\r\n  tft.setTextColor(ILI9341_BLUE); \r\n  tft.setTextSize(2);\r\n  tft.println(\"A_PROMINI_XPT2046\");\r\n  TS.setHandler(onTouch);\r\n}\r\n\r\nvoid isr() {}\r\nvoid loop() {\r\n  Serial.println(\"start sleep\");\r\n  delay(100);\r\n  digitalWrite(LED_PIN, 0);\r\n  tft.tft_sleep();\r\n  attachInterrupt(0, isr, FALLING);\r\n  set_sleep_mode(SLEEP_MODE_PWR_DOWN);\r\n  sleep_enable();\r\n  MCUCR |= 0x60;\r\n  MCUCR = (MCUCR &amp; 0xdf) | 0x40;\r\n  sleep_cpu();  \r\n  detachInterrupt(0);\r\n  \/\/ \u30bf\u30c3\u30c1\u691c\u51fa\r\n  digitalWrite(LED_PIN, 1);\r\n  tft.tft_wakeup();\r\n  TS.touch_loop();\r\n}<\/pre>\n<p>\u521d\u671f\u8a2d\u5b9a\u304c\u7d42\u308f\u308b\u3068\u6db2\u6676\u306e\u8868\u793a\u3082\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u3082\u6d88\u3057\u3066\u30b9\u30ea\u30fc\u30d7\u72b6\u614b\u306b\u5165\u3044\u308b\u3002\u30bf\u30c3\u30c1\u3092\u691c\u51fa\u3059\u308b\u3068\u3001\u30bf\u30c3\u30c1\u3057\u7d9a\u3051\u3066\u3044\u308b\u9593\u306f\u691c\u51fa\u3057\u305f\u5ea7\u6a19\u3092\u6db2\u6676\u4e0a\u306b\u8868\u793a\u3057\u7d9a\u3051\u308b\u3002<\/p>\n<h2>\u00a0\u5404\u90e8\u306e\u8aac\u660e<\/h2>\n<p>#define\u3067\u3001\u6db2\u6676\u5236\u5fa1\u7528\u306e\u30dd\u30fc\u30c8\u3092\u5b9a\u7fa9\u3057\u3001Adafruit_ILI9341\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 tft \u3092\u4f5c\u6210\u3002\u3055\u3089\u306b\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u8aad\u307f\u53d6\u308a\u7528\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9 TS \u3092\u4f5c\u6210\u3057\u3066\u3044\u308b\u3002\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u7528\u306e\u30b9\u30ec\u30fc\u30d6\u30bb\u30ec\u30af\u30c8\u306fD8\u306b\u5272\u308a\u5f53\u3066\u305f\u3002<\/p>\n<h6>void getTextMetrics(char* cpText, uint16_t&amp; tw, uint16_t&amp; th)<\/h6>\n<p>\u6db2\u6676\u4e0a\u306e\u540c\u3058\u4f4d\u7f6e\u306b\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u304b\u3089\u306e\u8aad\u307f\u53d6\u308a\u5024\u3092\u9023\u7d9a\u7684\u306b\u8868\u793a\u3059\u308b\u306b\u3042\u305f\u308a\u3001\u8868\u793a\u5bfe\u8c61\u306e\u77e9\u5f62\u306e\u5927\u304d\u3055\u3092\u5f97\u308b\u305f\u3081\u306b\u4f5c\u3063\u305f\u95a2\u6570\u3002\u3053\u306e\u95a2\u6570\u3092\u547c\u3076\u524d\u306b\u3001tft.setTextSize() \u306b\u3088\u3063\u3066\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba\u3092\u6307\u5b9a\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<h6>bool onTouch(int x, int y)<\/h6>\n<p>\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u30e9\u30a4\u30d6\u30e9\u30ea\u304b\u3089\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3055\u308c\u308b\u95a2\u6570\u3002\u5f15\u6570x, y\u306b\u306f\u6db2\u6676\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u540c\u69d8\u306e\u5ea7\u6a19\u7cfb\u3067\u4f4d\u7f6e\u304c\u4e0e\u3048\u3089\u308c\u308b\u3002\u6700\u521d\u306b\u8868\u793a\u4f4d\u7f6e\u77e9\u5f62\u306e\u5e45\u3068\u9ad8\u3055\u3092\u4f7f\u3063\u3066\u77e9\u5f62\u3092\u5857\u308a\u3064\u3076\u3057\u3001\u540c\u3058\u4f4d\u7f6e\u306b\u5f15\u6570\u3068\u3057\u3066\u5f97\u3089\u308c\u305f\u5ea7\u6a19\u3068\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u4fdd\u6301\u3059\u308b\u751f\u5ea7\u6a19\u3092\u8868\u793a\u3059\u308b\u3002<\/p>\n<h6>void setup()<\/h6>\n<p>ATmega328P\u306eADC\u3084\u30a2\u30ca\u30ed\u30b0\u30b3\u30f3\u30d1\u30ec\u30fc\u30bf\u306e\u52d5\u4f5c\u3092\u7981\u6b62\u3057\u3001\u6db2\u6676\u306e\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u3092\u30aa\u30d5\u306b\u3059\u308b\u3002\u305d\u3057\u3066ILI9341\u306b\u5bfe\u3057\u3066\u660e\u793a\u7684\u306b\u30ea\u30bb\u30c3\u30c8\u3092\u304b\u3051\u3001\u6db2\u6676\u8868\u793a\u306e\u305f\u3081\u306e\u521d\u671f\u5316\u3092\u884c\u3044\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u306e\u30dd\u30a4\u30f3\u30bf\u3092\u4e0e\u3048\u308b\u3002<\/p>\n<h6>void isr()<\/h6>\n<p>\u30b9\u30ea\u30fc\u30d7\u304b\u3089\u306e\u5fa9\u5e30\u7528\u306a\u306e\u3067\u3001\u4e2d\u8eab\u306f\u4f55\u3082\u66f8\u304f\u5fc5\u8981\u304c\u306a\u3044\u3002<\/p>\n<h6>void loop()<\/h6>\n<p>\u660e\u793a\u7684\u306b\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u3092\u6d88\u3057\u3001\u6db2\u6676\u8868\u793a\u3082\u30aa\u30d5\u306b\u3057\u3066\u304b\u3089\u30b9\u30ea\u30fc\u30d7\u30e2\u30fc\u30c9 (SLEEP_MODE_PWR_DOWN) \u306b\u5165\u308b\u3002\u30b9\u30ea\u30fc\u30d7\u4e2d\u306eBOD\u3082\u7981\u6b62\u3057\u3066\u3044\u308b\u3002<br \/>\n\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u306b\u62bc\u5727\u304c\u639b\u304b\u308b\u3068\u5272\u8fbc\u307f\u304c\u767a\u751f(D2\u304cLOW\u306b\u306a\u308b)\u3057\u3001\u30b9\u30ea\u30fc\u30d7\u304b\u3089\u5fa9\u5e30\u3057\u3066\u304f\u308b\u306e\u3067\u3001\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u306e\u70b9\u706f\u5f8c\u306b\u6db2\u6676\u306e\u8868\u793a\u3092\u518d\u958b\u3055\u305b\u3001\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u30e9\u30a4\u30d6\u30e9\u30ea\u306e touch_loop() \u3092\u547c\u3073\u51fa\u3059\u3002<\/p>\n<p>\u30bf\u30c3\u30c1\u304c\u7d9a\u3044\u3066\u3044\u308b\u9593\u306fonTouch() \u304c\u9023\u7d9a\u3057\u3066\u547c\u3073\u51fa\u3055\u308c\u308b\u3002\u30bf\u30c3\u30c1\u3055\u308c\u306a\u304f\u306a\u308b\u3068touch_loop() \u304b\u3089\u5e30\u3063\u3066\u304f\u308b\u306e\u3067\u3001loop() \u306e\u5148\u982d\u306b\u623b\u3063\u3066\u30b9\u30ea\u30fc\u30d7\u72b6\u614b\u306b\u5165\u308b\u3002<\/p>\n<h1>\u52d5\u4f5c<\/h1>\n<p>TFT\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30da\u30f3\u3067\u30bf\u30c3\u30c1\u3057\u3066\u3044\u308b\u6a21\u69d8\u3092\u52d5\u753b\u306b\u3057\u3066\u307f\u305f\u3002<\/p>\n<p><iframe loading=\"lazy\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/bjSsra1N9G8?rel=0?ecver=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>\u6db2\u6676\u306b\u30ab\u30e1\u30e9\u3060\u306e\u30ec\u30f3\u30ba\u3060\u306e\u304c\u6620\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u90e8\u5c4b\u3092\u6697\u304f\u3057\u3066\u64ae\u5f71\u3057\u305f\u3002\u30da\u30f3\u3092\u52d5\u304b\u3059\u3054\u3068\u306b\u5909\u63db\u3057\u305f\u5ea7\u6a19\u3068\u751f\u5ea7\u6a19\u3092\u8868\u793a\u3057\u3001\u30da\u30f3\u3092\u96e2\u3059\u3068\u6db2\u6676\u304c\u6d88\u3048(\u30d0\u30c3\u30af\u30e9\u30a4\u30c8\u30aa\u30d5)\u3001\u623b\u3059\u3068\u3059\u3050\u306b\u5fa9\u5e30\u3059\u308b\u3002<\/p>\n<figure id=\"attachment_6581\" aria-describedby=\"caption-attachment-6581\" style=\"width: 552px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/10\/77e1c1e409e8d7d8d16a3161cbd7f490.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-6581\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/10\/77e1c1e409e8d7d8d16a3161cbd7f490-552x414.jpg\" alt=\"A_PRO_MINI_ILI9341_TFT1\" width=\"552\" height=\"414\" \/><\/a><figcaption id=\"caption-attachment-6581\" class=\"wp-caption-text\">A_PRO_MINI_ILI9341_TFT1<\/figcaption><\/figure>\n<p>\u30bf\u30c3\u30c1\u3059\u308b\u3054\u3068\u306bTFT\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u52d5\u3044\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u9577\u3044\u30d6\u30ec\u30c3\u30c9\u30dc\u30fc\u30c9\u304b\u3089\u306f\u307f\u51fa\u3057\u305f\u4e0b\u306b\u9069\u5f53\u306a\u53f0\u3092\u304a\u3044\u3066\u3057\u306e\u3044\u3060\u3002\u3061\u3083\u3093\u3068\u3057\u305f\u30cf\u30b3\u306b\u5165\u308c\u3066\u3084\u3063\u305f\u65b9\u304c\u3044\u3044\u306e\u3060\u308d\u3046\u3002<\/p>\n<h2>\u304d\u3087\u3046\u306e\u307e\u3068\u3081<\/h2>\n<p>\u5b89\u3044\u88fd\u54c1\u3060\u304c\u3001\u8868\u793a\u3082\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u3082\u3061\u3083\u3093\u3068\u52d5\u3044\u3066\u3044\u308b\u3088\u3046\u3067\u5b89\u5fc3\u3057\u305f\u3002\u52d5\u753b\u3067\u306f\u30bf\u30c3\u30c1\u30da\u30f3\u3092\u4f7f\u3063\u3066\u3044\u308b\u304c\u3001\u6700\u521d\u306b\u8cb7\u3063\u305f\u88fd\u54c1\u306b\u306f\u4ed8\u5c5e\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u3002\u5225\u306eTFT\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u4ed8\u3044\u3066\u304d\u305f\u3082\u306e\u3092\u4f7f\u3063\u3066\u3044\u308b\u3002\u5c02\u7528\u306e\u30bf\u30c3\u30c1\u30da\u30f3\u304c\u306a\u304f\u3066\u3082\u3001\u30dc\u30fc\u30eb\u30da\u30f3\u3067\u3082\u7bb8\u3067\u3082\u3044\u3044\u3068\u306f\u601d\u3046\u306e\u3060\u304c\u3002<\/p>\n<p>\u6b21\u56de\u306f\u3001\u4eca\u56de\u306e\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u9023\u643a\u3059\u308b\u3088\u3046\u306a\u64cd\u4f5c\u30dc\u30bf\u30f3\u6a5f\u80fd\u3092\u3053\u3057\u3089\u3048\u3066\u3001\u305d\u306e\u4f7f\u7528\u4f8b\u3068\u3057\u3066\u30c6\u30ec\u30d3\u3060\u3051\u3092\u64cd\u4f5c\u3067\u304d\u308b\u30b7\u30f3\u30d7\u30eb\u306a\u30ea\u30e2\u30b3\u30f3\u3092\u8a66\u4f5c\u3057\u3066\u307f\u308b\u4e88\u5b9a\u3002\u30c6\u30ec\u30d3\u306b\u3082\u305f\u304f\u3055\u3093\u6a5f\u80fd\u304c\u3042\u308a\u3001\u305d\u306e\u30ea\u30e2\u30b3\u30f3\u306b\u3082\u6570\u591a\u304f\u306e\u30dc\u30bf\u30f3\u304c\u3042\u308b\u304c\u3001\u3088\u304f\u4f7f\u3046\u3082\u306e\u3060\u3051\u3092\u7528\u610f\u3059\u308b\u3002<\/p>\n<p>\u554f\u984c\u306f\u30012.4\u30a4\u30f3\u30c1\u306e\u6db2\u6676\u3084\u3001\u305d\u3053\u306b\u8868\u793a\u3067\u304d\u308b\u6587\u5b57\u304c\u3068\u3066\u3082\u5c0f\u3055\u3044\u3053\u3068\u3002\u8aad\u66f8\u7528\u306e\u30e1\u30ac\u30cd\u304c\u306a\u3044\u3068\u6587\u5b57\u304c\u8aad\u3081\u306a\u3044\u6050\u308c\u304c\u3042\u308b\u3002ILI9341\u3068TSC2046\u30d9\u30fc\u30b9\u306eTFT\u30e2\u30b8\u30e5\u30fc\u30eb\u306a\u3089\u3070\u540c\u3058\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u304c\u52d5\u304f\u3060\u308d\u3046\u304b\u3089\u3001\u3082\u3046\u3061\u3087\u3063\u3068\u5927\u304d\u306aTFT\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3044\u305f\u3044\u3002\u305f\u3060\u305d\u3046\u306a\u308b\u3068\u3001\u4f59\u8a08\u306b\u96fb\u6c17\u3092\u98df\u3063\u3066\u3057\u307e\u3046\u3060\u308d\u3046\u3053\u3068\u304c\u554f\u984c\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 \u4ee5\u524d\u306bamazon\u3067\u5b89\u304f\u8cb7\u3063\u305f2.4\u30a4\u30f3\u30c1\u306eTFT\u6db2\u6676\u30e2\u30b8\u30e5\u30fc\u30eb(\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u4ed8)\u3092Arduino PRO MINI\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3063\u3066\u307f\u305f\u3002\u524d\u304b\u3089\u305f\u307e\u306b\u4f5c\u3063\u3066\u3044\u308b\u8d64\u5916\u7dda\u30ea\u30e2\u30b3\u30f3\u306e\u64cd\u4f5c\u90e8\u3092\u3001\u30e1\u30ab\u30cb\u30ab\u30eb\u30b9\u30a4\u30c3\u30c1\u3067\u306f\u306a &hellip; <a href=\"https:\/\/okiraku-camera.tokyo\/blog\/?p=6487\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30bf\u30c3\u30c1\u30d1\u30cd\u30eb\u4ed8TFT\u6db2\u6676\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u307f\u308b<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[65,86],"class_list":["post-6487","post","type-post","status-publish","format-standard","hentry","category-programming","tag-arduino","tag-remocon"],"_links":{"self":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6487"}],"version-history":[{"count":0,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6487\/revisions"}],"wp:attachment":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}