{"id":2022,"date":"2014-08-20T09:46:57","date_gmt":"2014-08-20T16:46:57","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=2022"},"modified":"2023-02-08T04:25:59","modified_gmt":"2023-02-08T12:25:59","slug":"tft-lcd-display-with-ping-ultrasonic-sensor","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/tft-lcd-display-with-ping-ultrasonic-sensor\/","title":{"rendered":"TFT LCD Display with PING Ultrasonic Sensor"},"content":{"rendered":"<p>A good display is hard to find. So when I came across the\u00a0\u00a0<a href=\"https:\/\/www.adafruit.com\/product\/358\">Adafruit&#8217;s 1.8&#8243; 18-bit color TFT LCD display with microSD card breakout<\/a>\u00a0I couldn&#8217;t wait to get it working on our chipKIT boards.<\/p>\n<p>&nbsp;<\/p>\n<h3>Products I used from Adafruit:<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.adafruit.com\/products\/358\">1.8&#8243; TFT Screen<\/a><\/li>\n<li>Only the range finder in this <a href=\"https:\/\/www.adafruit.com\/products\/1715\">robot kit<\/a>, but you can get it on its own at <a href=\"http:\/\/www.pololu.com\/product\/1605\">Pololu<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/n-rr-opja44\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<p>In the video, I used a Parallax PING sensor to measure distance and output image data to the screen using a <a href=\"https:\/\/www.adafruit.com\/search?q=uc32\" target=\"_blank\" rel=\"noopener\">chipKIT uC32<\/a>. (You&#8217;re not limited to using the chipKIT uC32&#8211;any other board that supports SPI communication works too.)<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: left;\">You can see my code\u00a0<a href=\"https:\/\/github.com\/tom21091\/Adafruit-TFT\/archive\/master.zip\">here<\/a>.<\/p>\n<h3>What I did:<\/h3>\n<p>Adafruit provides\u00a0a good tutorial on how to wire the screen up\u00a0and get it working for Arduino boards <a href=\"https:\/\/learn.adafruit.com\/1-8-tft-display\">here<\/a>.<\/p>\n<figure id=\"attachment_2121\" aria-describedby=\"caption-attachment-2121\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2121\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-1.jpg\" alt=\"making sure to connect up the screen correctly\" width=\"600\" height=\"450\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-1.jpg 640w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-1-300x225.jpg 300w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-1-225x168.jpg 225w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-2121\" class=\"wp-caption-text\">Make sure to connect up the screen correctly!<\/figcaption><\/figure>\n<p>Then, I had to connect the LCD screen\u00a0to the chipKIT and make sure the pins corresponded to <a href=\"https:\/\/github.com\/tom21091\/Adafruit-TFT\">my code<\/a>.<\/p>\n<figure id=\"attachment_2122\" aria-describedby=\"caption-attachment-2122\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-3.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2122\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-3.jpg\" alt=\"Wiring up the uC32\" width=\"600\" height=\"450\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-3.jpg 640w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-3-300x225.jpg 300w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-3-225x168.jpg 225w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-3-600x450.jpg 600w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-2122\" class=\"wp-caption-text\">Wire up the uC32.<\/figcaption><\/figure>\n<p>Our demo file has some code pulled from Adafruit&#8217;s GFX library so that it will work on a chipKIT board. All I had to do was tweak the code (change the pins and make sure that the board was set right) so it would work on my UC32 PIC32 microcontroller.\u00a0I used a <a href=\"\/\/blog.blog.digilentinc.com\/index.php\/using-sparkfuns-nokia-5510-lcd-display\/\">similar approach to the one used in a previous blog post<\/a>\u00a0to create a bitmap array that could be output to the screen. The only difference is that I\u00a0added a function that can take a monochromatic bitmap and output it to the screen.<\/p>\n<p>&nbsp;<\/p>\n<p>For the completed demo,\u00a0I\u00a0used the PING sensor to measure distance and output a Digilent logo bitmap to the display on the screen, which is dependent on the distance from the sensor.<\/p>\n<figure id=\"attachment_2123\" aria-describedby=\"caption-attachment-2123\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2123\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-2.jpg\" alt=\"How to wire up the PING sensor\" width=\"600\" height=\"324\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-2.jpg 626w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-2-300x161.jpg 300w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-2-225x121.jpg 225w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-2123\" class=\"wp-caption-text\">How to wire up the PING sensor.<\/figcaption><\/figure>\n<p>I also used the PING sensor as a scope, which graphs the distance from an object to the sensor over time.<\/p>\n<p>You can see in the video below how the screen tracks the distance of my hand.<\/p>\n<p style=\"text-align: center;\"><iframe loading=\"lazy\" src=\"\/\/www.youtube.com\/embed\/OINDDMp4G-k\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>It was a lot of fun to be able to get a full color display on my chipKIT. \u00a0Check out the videos, the demo code, and make sure to head over the Adafruit to try out one of their displays with your own uC32!<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-2022 jlk' data-task='like' data-post_id='2022' data-nonce='e5335d04d0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-2022 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-2022 jlk' data-task='unlike' data-post_id='2022' data-nonce='e5335d04d0' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-2022 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-2022 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>A good display is hard to find. So when I came across the  Adafruit&#8217;s 1.8&#8243; 18-bit color TFT LCD display with microSD card breakout I couldn&#8217;t wait to get it working on our chipKIT boards.<\/p>\n","protected":false},"author":25,"featured_media":2122,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4327,1561],"tags":[],"ppma_author":[4474],"class_list":["post-2022","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-applications"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2014\/08\/TFT-Adafruit-connected-to-chipKIT-uc32-3.jpg","authors":[{"term_id":4474,"user_id":25,"is_guest":0,"slug":"tommywommy","display_name":"Tommy Kappenman","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/4c40e0e6752af7558f2705740585441a?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Kappenman","last_name_2":"","first_name":"Tommy","first_name_2":"","job_title":"","description":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/2022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=2022"}],"version-history":[{"count":1,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/2022\/revisions"}],"predecessor-version":[{"id":29674,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/2022\/revisions\/29674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/2122"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=2022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=2022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=2022"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=2022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}