{"id":153,"date":"2017-12-06T19:45:17","date_gmt":"2017-12-06T19:45:17","guid":{"rendered":"http:\/\/www.adrian-smith31.co.uk\/blog\/?p=153"},"modified":"2020-11-09T17:10:57","modified_gmt":"2020-11-09T17:10:57","slug":"arduino-scrolling-message-on-5x7-matrix","status":"publish","type":"post","link":"https:\/\/www.adrian-smith31.co.uk\/blog\/2017\/12\/arduino-scrolling-message-on-5x7-matrix\/","title":{"rendered":"Arduino scrolling clock and custom message on 5&#215;7 matrix"},"content":{"rendered":"<p><span style=\"color: #333300;\"><strong>Introduction<\/strong><\/span><\/p>\n<p>I&#8217;ve been playing around with a red 5&#215;7 dot matrix LED display module which I have had in my spares box for a while. I thought about making some sort of scrolling message display as an Arduino project but could not find any more of these modules online as I&#8217;d need at least another seven. However I did have an Arduino Nano, a small case with a scratched lid and a piece of veroboard that just happened to fit the box exactly.<\/p>\n<p>I needed to practice my programming skills and after a few attempts of trying to get the display connections right I was able to make some characters appear on the display. It wasn&#8217;t anything useful so following a few examples on the internet I ended up with a scrolling message that was hard coded into the program.<\/p>\n<figure id=\"attachment_160\" aria-describedby=\"caption-attachment-160\" style=\"width: 211px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0151.jpg\" target=\"_blank\" rel=\"attachment noopener wp-att-160 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-160 size-medium\" title=\"Arduino based scrolling message display\" src=\"http:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0151-211x300.jpg\" alt=\"Arduino based scrolling message display\" width=\"211\" height=\"300\" srcset=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0151-211x300.jpg 211w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0151-720x1024.jpg 720w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0151.jpg 745w\" sizes=\"auto, (max-width: 211px) 100vw, 211px\" \/><\/a><figcaption id=\"caption-attachment-160\" class=\"wp-caption-text\">Completed messaging display in ABS case<\/figcaption><\/figure>\n<p>For this to be of any use I needed to be able to upload messages to it so I wrote some code to store the incoming serial data into a buffer then into an array to be displayed. However I couldn&#8217;t get it working right; it took ages to transfer the message and every time you wanted to change the message you had to power it off and on again.<\/p>\n<p>It turned out I&#8217;d got some of the curly braces in the wrong positions in one of the &#8216;for&#8217; loops which was causing the delays. I stuffed it into the case (the scratch was on the part which would be cut out for the display window) and then thought, that&#8217;s nice and put it in the cupboard and forgot about it.<\/p>\n<p><!--more--><\/p>\n<p>The other day I dug it out and re-wrote the serial code and I now have a useable message display albeit with only one character displayed at once. It was good practice anyway and those parts wouldn&#8217;t have got used for anything else.<\/p>\n<p>Anyway here&#8217;s the project:-<\/p>\n<p><span style=\"color: #333300;\"><strong>The code<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">The code has gone through several revisions as I wanted to be able to overwrite the message without powering off the display so this now works. <del>I also wanted to make it a standalone device but I was unable to get the eeprom to work; I could get the message stored in the eeprom OK and read back to the serial port OK but it always displayed &#8220;32&#8221; on the LED display regardless of message content.<\/del> <\/span><\/p>\n<p><del><span style=\"color: #000000;\">I think this is the way the eeprom stores the data but for the life of me I could not get it to work. Maybe Ill give it another go in the future but for now here is the completed source code:-<\/span><\/del><\/p>\n<p><em>Update Feb 2018 &#8211; I have now got the eeprom to work. Messages are now remembered and displayed at the next power on. The message can be overwritten by sending another via the serial port. I have also learnt how to tell the compiler to keep text strings in flash memory instead of copying to SRAM which was wasting space. The updated source code can be found below:-<\/em><\/p>\n<p><a href=\"http:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/Scrolling_msg_display_with_eeprom.zip\" target=\"_blank\" rel=\"noopener noreferrer\">Scrolling message display with clock &#8211; updated<\/a><\/p>\n<p><span style=\"color: #333300;\"><strong>Building the circuit and case<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">I do not have a circuit diagram but the pin numbers used are explained in the code and I have also <a href=\"http:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/BM-20UE57NI.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">included the datasheet<\/a>\u00a0for the LED module I used. Most have the same pinouts but if you wanted to make this project you will have to check and change wiring accordingly. 220 ohm current limiting resistors will be required as the microcontroller&#8217;s pins will be directly connected to the LED module. This isn&#8217;t the best way to do it but it saves on components and is ideal for a single module.<\/span><\/p>\n<figure id=\"attachment_161\" aria-describedby=\"caption-attachment-161\" style=\"width: 274px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0149.jpg\" target=\"_blank\" rel=\"attachment noopener wp-att-161 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-161 size-medium\" src=\"http:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0149-274x300.jpg\" alt=\"\" width=\"274\" height=\"300\" srcset=\"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0149-274x300.jpg 274w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0149-768x841.jpg 768w, https:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2017\/12\/DSC_0149-935x1024.jpg 935w\" sizes=\"auto, (max-width: 274px) 100vw, 274px\" \/><\/a><figcaption id=\"caption-attachment-161\" class=\"wp-caption-text\">Letter &#8216;G&#8217; scrolling from right to left<\/figcaption><\/figure>\n<p>The case is a standard ABS project case with a cutout made by drilling the edges of the cutout then removing excess plastic with a stanley knife. I filed the edges smooth and stuck some clear perspex behind the cutout to protect the module from damage. A hole was cut into the side for the USB cable which is connected directly to the USB port on the nano.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Anyway here is a video of it working:-<\/p>\n\n<div class=\"youtube-embed\" itemprop=\"video\" itemscope itemtype=\"https:\/\/schema.org\/VideoObject\">\n\t<meta itemprop=\"url\" content=\"https:\/\/www.youtube.com\/v\/LPLWMlMTSm8\" \/>\n\t<meta itemprop=\"name\" content=\"Arduino scrolling clock and custom message on 5&#215;7 matrix\" \/>\n\t<meta itemprop=\"description\" content=\"Arduino scrolling clock and custom message on 5&#215;7 matrix\" \/>\n\t<meta itemprop=\"uploadDate\" content=\"2017-12-06T19:45:17+00:00\" \/>\n\t<meta itemprop=\"thumbnailUrl\" content=\"https:\/\/i.ytimg.com\/vi\/LPLWMlMTSm8\/default.jpg\" \/>\n\t<meta itemprop=\"embedUrl\" content=\"https:\/\/www.youtube.com\/embed\/LPLWMlMTSm8\" \/>\n\t<meta itemprop=\"height\" content=\"340\" \/>\n\t<meta itemprop=\"width\" content=\"560\" \/>\n\t<iframe loading=\"lazy\" style=\"border: 0;\" class=\"youtube-player\" width=\"560\" height=\"340\" src=\"https:\/\/www.youtube.com\/embed\/LPLWMlMTSm8\" allowfullscreen><\/iframe>\n<\/div>\n\n<p>&nbsp;<\/p>\n<p><span style=\"color: #333300;\"><strong>Improvements and ideas<\/strong><\/span><\/p>\n<p><span style=\"color: #000000;\">As I had mentioned earlier I plan to use the eeprom to store a message so the unit does not have to be connected to a PC \/ laptop and can be used standalone.\u00a0<\/span><\/p>\n<p>Another idea is to use a bluetooth module which can receive the message and output it in serial format. The library softwareserial would come in handy here. Also a GSM module could be another possibility of adding more functionality so text messages sent could be displayed.<\/p>\n<p>I also added a clock function so first it will display the date and time and then scroll the message which can be hard coded or updated via serial.<\/p>\n<p>If I decide to improve this project Ill update here.<\/p>\n<p><strong>Update Jan 2018 &#8211; the Fart Clock<\/strong><\/p>\n<p>Well I said I would update if I improved the scrolling message display. This revision adds a leading zero if the hour or minute was less than 10 e.g it used to display 10:6 now shows 10:06. The EEPROM now works; messages which are sent via serial port now are remembered even if powered off.<\/p>\n<p>I have also been playing with some gas sensors. Revision 3 now detects fart gas (methane and hydrogen) by using a MQ-2 sensor. If a threshold has been met the unit will replace the message displayed after the clock with a funny message depending on the severity of the fart. When the fart clears the message sent via the serial port is displayed again. Can be adapted to display anything if a sensor input threshold is met.<\/p>\n<p>Please note that due to the variations in sensors \/ sensor modules I have put sample thresholds in the code. You will need to adjust these threshold values accordingly depending on the sensor you have. E.g one sensor outputs 2-4V depending on gas concentration whereas mine gave 20mv in clean air and went up to 1V when exposed to some gas. As a guide an analog value of 400 is 2V.<\/p>\n<p>You can download the revised code <a href=\"http:\/\/www.adrian-smith31.co.uk\/blog\/wp-content\/uploads\/2018\/02\/Fart_Clock.zip\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a><\/p>\n<p>Please note that the scrolling message base code is based on Eric Lathrop&#8217;s code which I had used as an example and was unable to find it again. Anyway I came across it today and his link to his Github page is here\u00a0<a href=\"https:\/\/github.com\/ericlathrop\/LedGrid\">https:\/\/github.com\/ericlathrop\/LedGrid<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction I&#8217;ve been playing around with a red 5&#215;7 dot matrix LED display module which I have had in my spares box for a while. I thought about making some sort of scrolling message display as an Arduino project but could not find any more of these modules online as I&#8217;d need at least another [&hellip;]<\/p>\n","protected":false},"author":179,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Arduino scrolling clock and custom message on 5x7 matrix - Adrian's electronics blog","description":"Introduction I've been playing around with a red 5x7 dot matrix LED display module which I have had in my spares box for a while. I thought about making some so"},"footnotes":""},"categories":[4,5],"tags":[],"class_list":["post-153","post","type-post","status-publish","format-standard","hentry","category-microcontrollers","category-projects"],"_links":{"self":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts\/153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/users\/179"}],"replies":[{"embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":33,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"predecessor-version":[{"id":1061,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/posts\/153\/revisions\/1061"}],"wp:attachment":[{"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.adrian-smith31.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}