{"id":1840,"date":"2013-01-26T22:26:36","date_gmt":"2013-01-26T22:26:36","guid":{"rendered":"https:\/\/blog.ecotronics.ch\/wordpress\/?p=1840"},"modified":"2013-02-03T19:08:39","modified_gmt":"2013-02-03T19:08:39","slug":"multiplexed-4-digit-7-segment-led-display-mit-arduino-ansteuern","status":"publish","type":"post","link":"https:\/\/blog.ecotronics.ch\/wordpress\/?p=1840","title":{"rendered":"Multiplexed 4 digit 7 segment led display mit Arduino ansteuern"},"content":{"rendered":"<div id=\"attachment_1846\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplayMitBuchstabenUndZahlen.jpg\"><img aria-describedby=\"caption-attachment-1846\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-1846\" title=\"4 Digit 7 Segment LED Display mit Buchstaben und Zahlen\" src=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplayMitBuchstabenUndZahlen-300x169.jpg\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplayMitBuchstabenUndZahlen-300x169.jpg 300w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplayMitBuchstabenUndZahlen-150x84.jpg 150w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplayMitBuchstabenUndZahlen-400x225.jpg 400w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplayMitBuchstabenUndZahlen.jpg 613w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1846\" class=\"wp-caption-text\">4 Digit 7 Segment LED Display mit Buchstaben und Zahlen<\/p><\/div>\n<p>Diese ersten Versuche mit einem <strong>4-Digit-7-Segment-LED-Display <\/strong>sind eine <strong>Minimalvariante ohne Transistoren, zus\u00e4tzliche Shift-Register oder ICs<\/strong>. Auch<strong> auf Libraries habe ich verzichtet<\/strong>, um besser zu begreifen, wie die Ansteuerung des Displays funktioniert. Das erm\u00f6glicht mir, neben den \u00fcblichen <strong>Zahlen <\/strong>auch <strong>Buchstaben<\/strong> auszugeben (die meisten jedenfalls), was in den Libraries im Normalfall nicht vorgesehen ist. Allerdings verwende ich im Code Teile der Library <strong>SevSeg <\/strong>von Dean Reading.<\/p>\n<h1>Projektziel<\/h1>\n<p><strong>Zahlen <\/strong>und &#8211; soweit dies mit einem 7-Segment-Display \u00fcberhaupt m\u00f6glich ist &#8211; <strong>Buchstaben <\/strong>auf einem <strong>4-Digit-7-Segment-LED-Display anzeigen<\/strong>, wobei die anzuzeigenden Zeichen \u00fcber die <strong>serielle Schnittstelle<\/strong> eingelesen werden.<\/p>\n<h1>Komponenten<\/h1>\n<div id=\"attachment_1851\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/Multiplexed4Digit7SegmentLEDDisplay12Pins_600.jpg\"><img aria-describedby=\"caption-attachment-1851\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-1851 \" title=\"Multiplexed 4 Digit7 Segment LED Display mit 12 Pins, common cathode\" src=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/Multiplexed4Digit7SegmentLEDDisplay12Pins_600-300x178.jpg\" alt=\"\" width=\"300\" height=\"178\" srcset=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/Multiplexed4Digit7SegmentLEDDisplay12Pins_600-300x178.jpg 300w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/Multiplexed4Digit7SegmentLEDDisplay12Pins_600-150x89.jpg 150w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/Multiplexed4Digit7SegmentLEDDisplay12Pins_600-400x238.jpg 400w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/Multiplexed4Digit7SegmentLEDDisplay12Pins_600.jpg 600w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1851\" class=\"wp-caption-text\">Multiplexed 4 Digit7 Segment LED Display mit 12 Pins, common cathode<\/p><\/div>\n<p>Das vorliegende Beispiel verwendet ein <strong>multiplexed Display<\/strong> (nur <strong>12 Pins<\/strong> statt 16) in der Variante common cathode, d.h. die 4 Pins f\u00fcr die 4 Zeichen werden an GND und die 8 Pins f\u00fcr die 7 Segmente und den Dezimalpunkt am Strom angeschlossen. Es gibt unz\u00e4hlige LED Displays mit den verschiedensten Verkabelungen, deshalb ben\u00f6tigt man unbedingt das richtige Datenblatt.<\/p>\n<ul>\n<li>1 Arduino UNO R3<\/li>\n<li>1 Steckbrett<\/li>\n<li>1 multiplexed 4-Digit-7-Segment LED Display <strong>LN3461AS2B<\/strong>, common cathode, 12 Pins (<a href=\"http:\/\/www.play-zone.ch\/de\/4-zeichen-7-segment-display-12pin.html\" target=\"_blank\">Bezugsquelle Schweiz<\/a>, <a href=\"http:\/\/www.play-zone.ch\/de\/fileuploader\/download\/download\/?d=1&amp;file=custom%2Fupload%2FFile-1356273109.pdf\" target=\"_blank\">Datenblatt<\/a>)<\/li>\n<li>4 Widerst\u00e4nde 680 Ohm<\/li>\n<li>12 Jumperkabel M\/M<\/li>\n<li>ein paar Drahtverbindungen, damit das Display im Kabelsalat nicht total verschwindet<\/li>\n<\/ul>\n<p>Der Verzicht auf Transistoren f\u00fchrt dazu, dass die Segmente, die eigentlich <strong>1.8 V<\/strong> und <strong>20mA<\/strong> pro Segment schlucken, mit Strom unterversorgt sind und nicht sehr hell leuchten. F\u00fcr erste Experimente und f\u00fcr eine Anzeige im Dunkeln reicht es aber alle Male.<\/p>\n<p><strong>Multiplexing <\/strong>bedeutet \u00fcbrigens im Zusammenhang mit diesem Display, <strong>dass von den 4 Ziffern immer nur 1 gleichzeitig angeschaltet ist<\/strong>. Macht man das genug schnell, dann wird das tr\u00e4ge menschliche Auge \u00fcbert\u00f6lpelt und man meint, alle 4 Ziffern gleichzeitig leuchten zu sehen. Wer es genauer wissen will, findet im Web Dutzende von guten Erkl\u00e4rungen, z.B. <a href=\"http:\/\/www.mikrocontroller.net\/articles\/AVR-Tutorial:_7-Segment-Anzeige#Mehrere_7-Segment_Anzeigen_.28Multiplexen.29\">hier<\/a>.<\/p>\n<h1>Best\u00fcckungsplan und Verkabelung<\/h1>\n<div id=\"attachment_1849\" style=\"width: 132px\" class=\"wp-caption alignright\"><a href=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplay_NummerierungDerSegmente.jpg\"><img aria-describedby=\"caption-attachment-1849\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1849 \" title=\"LED Display - Nummerierung der 7 Segmente\" src=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplay_NummerierungDerSegmente.jpg\" alt=\"\" width=\"122\" height=\"173\" srcset=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplay_NummerierungDerSegmente.jpg 122w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/LEDDisplay_NummerierungDerSegmente-105x150.jpg 105w\" sizes=\"(max-width: 122px) 100vw, 122px\" \/><\/a><p id=\"caption-attachment-1849\" class=\"wp-caption-text\">LED Display - Nummerierung der 7 Segmente<\/p><\/div>\n<p>Damit die Anzeige funktioniert und nicht einfach St\u00e4bchensalat ausgibt, muss die Verkabelung nat\u00fcrlich genau stimmen. Die Pins des Displays werden wie \u00fcblich <strong>von 1 unten links \u00fcber 6 unten rechts bis zu 12 oben links im Gegenuhrzeigersinn nummeriert<\/strong>. Zwischen die 4 Digit-Pins und die zugeh\u00f6rigen Arduino-Pins kommt je ein Widerstand.<\/p>\n<p>Hier meine Verkabelung von Display-Pins mit Arduino-Pins, wie im verlinkten Datenblatt beschrieben. Die Segmente dagegen werden von oben im Uhrzeigersinn mit A bis G bezeichnet, wobei der mittlere Querstrich G ist.<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr height=\"19\">\n<td width=\"154\" height=\"19\"><strong>Was<\/strong><\/td>\n<td width=\"83\" align=\"right\"><strong>Display Pin<\/strong><\/td>\n<td width=\"83\" align=\"right\"><strong>Arduino Pin<\/strong><\/td>\n<td><strong>Achtung<\/strong><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Digit 1<\/td>\n<td align=\"right\">12<\/td>\n<td align=\"right\">2<\/td>\n<td>680-Ohm Widerstand dazwischen<\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Digit 2<\/td>\n<td align=\"right\">9<\/td>\n<td align=\"right\">3<\/td>\n<td>680-Ohm Widerstand dazwischen<\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Digit 3<\/td>\n<td align=\"right\">8<\/td>\n<td align=\"right\">4<\/td>\n<td>680-Ohm Widerstand dazwischen<\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Digit 4<\/td>\n<td align=\"right\">6<\/td>\n<td align=\"right\">5<\/td>\n<td>680-Ohm Widerstand dazwischen<\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Segment A (oben)<\/td>\n<td align=\"right\">11<\/td>\n<td align=\"right\">6<\/td>\n<td><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Segment B<br \/>\n(rechts oben)<\/td>\n<td align=\"right\">7<\/td>\n<td align=\"right\">7<\/td>\n<td><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Segment C<br \/>\n(rechts unten)<\/td>\n<td align=\"right\">4<\/td>\n<td align=\"right\">8<\/td>\n<td><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Segment D (unten)<\/td>\n<td align=\"right\">2<\/td>\n<td align=\"right\">9<\/td>\n<td><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Segment E<br \/>\n(links unten)<\/td>\n<td align=\"right\">1<\/td>\n<td align=\"right\">10<\/td>\n<td><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Segment F<br \/>\n(links oben)<\/td>\n<td align=\"right\">10<\/td>\n<td align=\"right\">11<\/td>\n<td><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">Segment G (Mittelstrich)<\/td>\n<td align=\"right\">5<\/td>\n<td align=\"right\">12<\/td>\n<td><\/td>\n<\/tr>\n<tr height=\"19\">\n<td height=\"19\">DP Dezimalpunkt<\/td>\n<td align=\"right\">3<\/td>\n<td align=\"right\">13<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div id=\"attachment_1860\" style=\"width: 610px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/4digit7segmentLedDisplay_LN3461AS2B_Steckplatine_600.jpg\"><img aria-describedby=\"caption-attachment-1860\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1860\" title=\"4 digit 7 segment Display LN3461AS2B Steckplatine\" src=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/4digit7segmentLedDisplay_LN3461AS2B_Steckplatine_600.jpg\" alt=\"\" width=\"600\" height=\"497\" srcset=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/4digit7segmentLedDisplay_LN3461AS2B_Steckplatine_600.jpg 600w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/4digit7segmentLedDisplay_LN3461AS2B_Steckplatine_600-300x248.jpg 300w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/4digit7segmentLedDisplay_LN3461AS2B_Steckplatine_600-150x124.jpg 150w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/4digit7segmentLedDisplay_LN3461AS2B_Steckplatine_600-400x331.jpg 400w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-1860\" class=\"wp-caption-text\">4 digit 7 segment Display LN3461AS2B Steckplatine<\/p><\/div>\n<h1>Code<\/h1>\n<p>Der Code geh\u00f6rt einmal mehr ins Kapitel &#8220;Weshalb ich C von ganzem Herzen hasse!&#8221;. Er ist sehr lang, besteht aber aus unz\u00e4hligen fast identischen Schritten und Wiederholungen, da es mir nicht gelungen ist, in C einen Array aus anderen Arrays zusammenzusetzen. Dass es t\u00fcckisch ist, einen Array als Parameter in eine Methode zu \u00fcbergeben, dar\u00fcber habe ich ja in meinem <a href=\"https:\/\/www.ecotronics.ch\/ecotron\/arduinocheatsheet.htm#Prog_Typen\" target=\"_blank\">Arduino Cheat Sheet<\/a> bereits geklagt. Deshalb steht der ganze Code ohne weitere Unterteilung im Loop.<\/p>\n<p>Das Einlesen aus der seriellen Schnittstelle wiederum habe ich bereits im Artikel &#8220;<a href=\"https:\/\/blog.ecotronics.ch\/wordpress\/2012\/arduino-als-uhr\/\" target=\"_blank\">Arduino als Uhr<\/a>&#8221; beschrieben.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/*  4 digit 7 segment LED display common cathode\r\n *  display shows numbers and letters from the serial interface\r\n *  without the use of a library\r\n *  every digit can have a decimal point\r\n *  decimal point can be entered with . or ,\r\n *\r\n * Author: Silvia Rothen, rothen ecotronics, Bern, Switzerland\r\n * part of the code is from the library SevSeg by Dean Reading\r\n *\/\r\n \r\nboolean DigitOn = LOW;\r\nboolean DigitOff = HIGH;\r\nboolean SegOn=HIGH;\r\nboolean SegOff=LOW;\r\nint DigitPins[] = {2, 3, 4, 5};\r\nint SegmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};\r\n\r\n\/\/looks terrible, but I didn't find a way to copy Arrays or merge them from parts\r\n\/\/N is for numbers and NxP is a number with a decimal point behind\r\nint BLANK[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW};\r\nint N0[]    = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW};\r\nint N0P[]   = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, HIGH};\r\nint N1[]    = {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW};\r\nint N1P[]   = {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW, HIGH};\r\nint N2[]    = {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH, LOW};\r\nint N2P[]   = {HIGH, HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH};\r\nint N3[]    = {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH, LOW};\r\nint N3P[]   = {HIGH, HIGH, HIGH, HIGH, LOW, LOW, HIGH, HIGH};\r\nint N4[]    = {LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH, LOW};\r\nint N4P[]   = {LOW, HIGH, HIGH, LOW, LOW, HIGH, HIGH, HIGH};\r\nint N5[]    = {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH, LOW};\r\nint N5P[]   = {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH, HIGH};\r\nint N6[]    = {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, LOW};\r\nint N6P[]   = {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH};\r\nint N7[]    = {HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW};\r\nint N7P[]   = {HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW, HIGH};\r\nint N8[]    = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW};\r\nint N8P[]   = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH};\r\nint N9[]    = {HIGH, HIGH, HIGH, HIGH, LOW, HIGH, HIGH, LOW};\r\nint N9P[]   = {HIGH, HIGH, HIGH, HIGH, LOW, HIGH, HIGH, HIGH};\r\nint MIN[]   = {LOW, LOW, LOW, LOW, LOW, LOW, HIGH, LOW};\r\n\/\/The letters K, M, N, T, V, W, Z are off limits with a 7 segment display\r\n\/\/Some letters like D, G, Q are hard to recognize, as D is like O and G like 6\r\nint A[] = {HIGH, HIGH, HIGH, LOW, HIGH, HIGH, HIGH, LOW};\r\nint B[] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW};\r\nint C[] = {HIGH, LOW, LOW, HIGH, HIGH, HIGH, LOW, LOW};\r\nint D[] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW};\r\nint E[] = {HIGH, LOW, LOW, HIGH, HIGH, HIGH, HIGH, LOW};\r\nint F[] = {HIGH, LOW, LOW, LOW, HIGH, HIGH, HIGH, LOW};\r\nint G[] = {HIGH, LOW, HIGH, HIGH, HIGH, HIGH, HIGH, LOW};\r\nint H[] = {LOW, HIGH, HIGH, LOW, HIGH, HIGH, HIGH, LOW};\r\nint I[] = {LOW, HIGH, HIGH, LOW, LOW, LOW, LOW, LOW};\r\nint J[] = {LOW, HIGH, HIGH, HIGH, HIGH, LOW, LOW, LOW};\r\nint L[] = {LOW, LOW, LOW, HIGH, HIGH, HIGH, LOW, LOW};\r\nint O[] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW};\r\nint P[] = {HIGH, HIGH, LOW, LOW, HIGH, HIGH, HIGH, LOW};\r\nint Q[] = {HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, HIGH};\r\nint R[] = {HIGH, HIGH, HIGH, LOW, HIGH, HIGH, HIGH, LOW};\r\nint S[] = {HIGH, LOW, HIGH, HIGH, LOW, HIGH, HIGH, LOW};\r\nint U[] = {LOW, HIGH, HIGH, HIGH, HIGH, HIGH, LOW, LOW};\r\nint Y[] = {LOW, HIGH, HIGH, HIGH, LOW, HIGH, HIGH, LOW};\r\n\r\n\/\/Array of pointers for the 4 digits\r\nint* lights[4];\r\n\r\n\/\/char array coming from the serial interface\r\n\/\/4 numbers or chars, 4 optional decimal points, 1 end-of-line char\r\nchar incoming[9] = {}; \r\n\r\nvoid setup() {\r\n  Serial.begin(9600);\r\n\r\n  for (byte digit=0;digit&lt;4;digit++) {\r\n    pinMode(DigitPins[digit], OUTPUT);\r\n  }\r\n  for (byte seg=0;seg&lt;8;seg++) {\r\n    pinMode(SegmentPins[seg], OUTPUT);\r\n  }\r\n  \/\/initialize display with 1.234\r\n  lights[0] = N1P;\r\n  lights[1] = N2;\r\n  lights[2] = N3;\r\n  lights[3] = N4;\r\n}\r\n\r\nvoid loop() {\r\n  \/\/read the numbers and \/ or chars from the serial interface\r\n  if (Serial.available() &gt; 0) {\r\n    int i = 0;\r\n    \/\/clear the array of char \r\n    memset(incoming, 0, sizeof(incoming));\r\n    while (Serial.available() &gt; 0 &amp;&amp; i &lt; sizeof(incoming) - 1) {\r\n      incoming[i] = Serial.read();\r\n      i++;\r\n      delay(3);\r\n    }\r\n    Serial.println(incoming); \r\n    \r\n    \/\/tmp is for the incoming string and counter for the 4 digits\r\n    int counter = -1;\r\n    for (int tmp = 0; tmp &lt; 9; tmp++) {\r\n      counter++;\r\n      switch(incoming[tmp]){\r\n        case '0': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N0P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N0; \r\n          }\r\n          break;\r\n        case '1': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N1P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N1; \r\n          }\r\n          break;\r\n        case '2': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N2P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N2; \r\n          }\r\n          break;\r\n        case '3': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N3P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N3; \r\n          }\r\n          break;\r\n        case '4': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N4P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N4; \r\n          }\r\n          break;\r\n        case '5': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N5P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N5; \r\n          }\r\n          break;\r\n        case '6': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N6P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N6; \r\n          }\r\n          break;\r\n        case '7': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N7P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N7; \r\n          }\r\n          break;\r\n        case '8': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N8P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N8; \r\n          }\r\n          break;\r\n        case '9': \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            lights[counter] = N9P;\r\n            tmp++;\r\n          } else {\r\n            lights[counter] = N9; \r\n          }\r\n          break;\r\n        case '-':\r\n          lights[counter] = MIN; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        \/\/with letters the decimal point is ignored!\r\n        \/\/if you need it, just write AP, BP etc with HIGH in the last position\r\n        case 'a': \/\/falls through to the next case\r\n        case 'A': \r\n          lights[counter] = A; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'b': \/\/falls through to the next case\r\n        case 'B': \r\n          lights[counter] = B; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'c': \/\/falls through to the next case\r\n        case 'C': \r\n          lights[counter] = C; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'd': \/\/falls through to the next case\r\n        case 'D': \r\n          lights[counter] = D; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'e': \/\/falls through to the next case\r\n        case 'E': \r\n          lights[counter] = E; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'f': \/\/falls through to the next case\r\n        case 'F': \r\n          lights[counter] = F; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'g': \/\/falls through to the next case\r\n        case 'G': \r\n          lights[counter] = G; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'h': \/\/falls through to the next case\r\n        case 'H': \r\n          lights[counter] = H; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'i': \/\/falls through to the next case\r\n        case 'I': \r\n          lights[counter] = I; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'j': \/\/falls through to the next case\r\n        case 'J': \r\n          lights[counter] = J; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'l': \/\/falls through to the next case\r\n        case 'L': \r\n          lights[counter] = L; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'o': \/\/falls through to the next case\r\n        case 'O': \r\n          lights[counter] = O; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'p': \/\/falls through to the next case\r\n        case 'P': \r\n          lights[counter] = P; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'q': \/\/falls through to the next case\r\n        case 'Q': \r\n          lights[counter] = Q; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'r': \/\/falls through to the next case\r\n        case 'R': \r\n          lights[counter] = R; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 's': \/\/falls through to the next case\r\n        case 'S': \r\n          lights[counter] = S; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'u': \/\/falls through to the next case\r\n        case 'U': \r\n          lights[counter] = U; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;        \r\n        case 'y': \/\/falls through to the next case\r\n        case 'Y': \r\n          lights[counter] = Y; \r\n          if (tmp  &lt; 8 &amp;&amp; (incoming[tmp + 1] == '.' || incoming[tmp + 1] == ',')) {\r\n            tmp++;\r\n          } \r\n          break;       \r\n        case 1 ... 43: counter--; break;\/\/special chars are ignored \r\n        \/\/44 to 46 are , - .\r\n        case 47: counter--; break;\/\/special chars are ignored \r\n        \/\/chars between Z and a\r\n        case 91 ... 96: counter--; break;\/\/special chars are ignored \r\n        case 123 ... 127: counter--; Serial.println(&quot;above 122&quot;); break;\/\/special chars are ignored \r\n        \r\n        default: lights[counter] = BLANK;\r\n      }\r\n    } \/\/end for\r\n    \r\n    \/\/show the input values\r\n    for (int y = 0; y &lt; 4; y++) {\r\n      Serial.print(y);\r\n      Serial.print(&quot;: &quot;);\r\n      for (int z = 0; z &lt; 8; z++) {\r\n        Serial.print(lights[y][z]);\r\n      }\r\n      Serial.println(&quot;&quot;);\r\n    }\r\n  } \/\/end if, i.e. reading from serial interface\r\n\r\n  \/\/This part of the code is from the library SevSeg by Dean Reading\r\n  for (byte seg=0;seg&lt;8;seg++) {\r\n    \/\/Turn the relevant segment on\r\n    digitalWrite(SegmentPins[seg],SegOn);\r\n\r\n    \/\/For each digit, turn relevant digits on\r\n    for (byte digit=0;digit&lt;4;digit++){\r\n      if (lights[digit][seg]==1) {\r\n        digitalWrite(DigitPins[digit],DigitOn);\r\n      }\r\n      \/\/delay(200); \/\/Uncomment this to see it in slow motion\r\n    }\r\n    \/\/Turn all digits off\r\n    for (byte digit=0;digit&lt;4;digit++){\r\n      digitalWrite(DigitPins[digit],DigitOff);\r\n    }\r\n\r\n    \/\/Turn the relevant segment off\r\n    digitalWrite(SegmentPins[seg],SegOff);\r\n  } \/\/end of for\r\n}\r\n\r\n<\/pre>\n<h1>Demo<\/h1>\n<p>Auf dem Screenshot sieht man Arduino mit Steckbrett, Verkabelung und LED Display.<\/p>\n<div id=\"attachment_1868\" style=\"width: 553px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/ArduinoMit4digit7segmentLedDisplay_LN3461AS2B_600.jpg\"><img aria-describedby=\"caption-attachment-1868\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1868\" title=\"Arduino mit 4 digit 7 segment LED Display LN3461AS2B\" src=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/ArduinoMit4digit7segmentLedDisplay_LN3461AS2B_600.jpg\" alt=\"\" width=\"543\" height=\"600\" srcset=\"https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/ArduinoMit4digit7segmentLedDisplay_LN3461AS2B_600.jpg 543w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/ArduinoMit4digit7segmentLedDisplay_LN3461AS2B_600-271x300.jpg 271w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/ArduinoMit4digit7segmentLedDisplay_LN3461AS2B_600-135x150.jpg 135w, https:\/\/blog.ecotronics.ch\/wordpress\/wp-content\/uploads\/2013\/01\/ArduinoMit4digit7segmentLedDisplay_LN3461AS2B_600-400x441.jpg 400w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/a><p id=\"caption-attachment-1868\" class=\"wp-caption-text\">Arduino mit 4 digit 7 segment LED Display LN3461AS2B<\/p><\/div>\n<p>Im Video zeige ich, wie man mit Eingaben in der seriellen Schnittstelle Zahlen- oder Buchstabenfolgen auf dem LED Display anzeigen kann.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"http:\/\/www.youtube.com\/embed\/85iTcxOWKr8?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p id=\"caption-attachment-1846\" class=\"wp-caption-text\">4 Digit 7 Segment LED Display mit Buchstaben und Zahlen<\/p>\n<p>Diese ersten Versuche mit einem 4-Digit-7-Segment-LED-Display sind eine Minimalvariante ohne Transistoren, zus\u00e4tzliche Shift-Register oder ICs. Auch auf Libraries habe ich verzichtet, um besser zu begreifen, wie die Ansteuerung des Displays funktioniert. Das erm\u00f6glicht mir, neben den \u00fcblichen Zahlen auch Buchstaben auszugeben (die meisten [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":1846,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[160,158],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1840"}],"collection":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1840"}],"version-history":[{"count":33,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1840\/revisions"}],"predecessor-version":[{"id":1893,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1840\/revisions\/1893"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/1846"}],"wp:attachment":[{"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1840"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1840"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ecotronics.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}