{"id":1291,"date":"2014-08-23T07:24:55","date_gmt":"2014-08-23T07:24:55","guid":{"rendered":"http:\/\/41j.com\/blog\/?p=1291"},"modified":"2014-08-23T11:59:03","modified_gmt":"2014-08-23T11:59:03","slug":"8x8-led-matrix-on-an-arduino","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2014\/08\/8x8-led-matrix-on-an-arduino\/","title":{"rendered":"8&#215;8 LED matrix on an Arduino"},"content":{"rendered":"<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/ZY0pqepZSnI?list=UU-uyS_Jg-GOqq2kuGcvaXWg\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>I picked a SZ410788K 8&#215;8 LED matrix out of my junk bin today and decided to play around with it. It cost me about 1USD in Aitendo, Akihabara. A little googling brought up the following:<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2014\/08\/8x8pinout.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2014\/08\/8x8pinout.gif\" alt=\"8x8pinout\" width=\"966\" height=\"658\" class=\"aligncenter size-full wp-image-1294\" \/><\/a><\/p>\n<p>I decided to hook it up to an Arduino (yea I know, I know).<\/p>\n<p>(more to follow)<\/p>\n<p>Here&#8217;s some quick code that scans the matrix:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\nvoid setup() {\r\n  \/\/ set the digital pin as output:\r\n  pinMode(2, OUTPUT);     \r\n  pinMode(3, OUTPUT);       \r\n  pinMode(3, OUTPUT);       \r\n  pinMode(4, OUTPUT);       \r\n  pinMode(5, OUTPUT);       \r\n  pinMode(6, OUTPUT);       \r\n  pinMode(7, OUTPUT);       \r\n  pinMode(8, OUTPUT);       \r\n  pinMode(9, OUTPUT);       \r\n  pinMode(10, OUTPUT);       \r\n  pinMode(11, OUTPUT);       \r\n  pinMode(12, OUTPUT);       \r\n  pinMode(13, OUTPUT); \r\n  \r\n  pinMode(A5, OUTPUT);       \r\n  pinMode(A4, OUTPUT);       \r\n  pinMode(A3, OUTPUT);       \r\n  pinMode(A2, OUTPUT);       \r\n  \r\n}\r\n\r\nvoid flash(int x,int y) {\r\n  \r\n   int state1=HIGH;\r\n   int state2=LOW;\r\n   \r\n   for(int n=0;n&lt;2;n++) {\r\n  \r\n   if(n==0) {\r\n     state1=HIGH;\r\n     state2=LOW;\r\n   } else {\r\n     state1=LOW;\r\n     state2=LOW;\r\n   }\r\n   if(x==0) digitalWrite(8, state1); else digitalWrite(8, state2);\r\n   if(x==1) digitalWrite(9, state1); else digitalWrite(9, state2);\r\n   if(x==2) digitalWrite(10, state1); else digitalWrite(10, state2);\r\n   if(x==3) digitalWrite(11, state1); else digitalWrite(11, state2);\r\n   if(x==4) digitalWrite(A5, state1); else digitalWrite(A5, state2);\r\n   if(x==5) digitalWrite(A4, state1); else digitalWrite(A4, state2);\r\n   if(x==6) digitalWrite(A3, state1); else digitalWrite(A3, state2);\r\n   if(x==7) digitalWrite(A2, state1); else digitalWrite(A2, state2);\r\n  \r\n   if(y==0) digitalWrite(12, state1); else digitalWrite(12, state2);\r\n   if(y==1) digitalWrite(13, state1); else digitalWrite(13, state2);\r\n   if(y==2) digitalWrite(2, state1);  else digitalWrite(2, state2);\r\n   if(y==3) digitalWrite(3, state1);  else digitalWrite(3, state2);\r\n   if(y==4) digitalWrite(4, state1);  else digitalWrite(4, state2);\r\n   if(y==5) digitalWrite(5, state1);  else digitalWrite(5, state2);\r\n   if(y==6) digitalWrite(6, state1);  else digitalWrite(6, state2);\r\n   if(y==7) digitalWrite(7, state1);  else digitalWrite(7, state2);\r\n   \r\n   if(n==0) delay(50);\r\n   }\r\n}\r\n\r\n\r\nvoid loop()\r\n{\r\n\r\n  for(int x=0;x&lt;8;x++) {\r\n    for(int y=0;y&lt;8;y++) {\r\n      flash(x,y);\r\n    }\r\n  }\r\n\r\n}\r\n<\/pre>\n<p>The pins are connected as follows:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nArduino   Matrix\r\n2         K6\r\n3         K5\r\n4         K4\r\n5         K3\r\n6         K2\r\n7         K1\r\n8         K8\r\n9         K7\r\n10        A8 \r\n11        A7\r\n12        A6\r\n13        A5\r\nA5        A4\r\nA4        A3\r\nA3        A2\r\nA2        A1\r\n<\/pre>\n<p>A 2N3904 is used to switch the grounds in on the A pins. So the circuit looks like this:<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2014\/08\/8x8diag.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2014\/08\/8x8diag-1024x513.jpg\" alt=\"8x8diag\" width=\"700\" height=\"350\" class=\"aligncenter size-large wp-image-1299\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2014\/08\/8x8diag-1024x513.jpg 1024w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2014\/08\/8x8diag-300x150.jpg 300w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2014\/08\/8x8diag.jpg 1363w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I picked a SZ410788K 8&#215;8 LED matrix out of my junk bin today and decided to play around with it. It cost me about 1USD in Aitendo, Akihabara. A little googling brought up the following: I decided to hook it up to an Arduino (yea I know, I know). (more to follow) Here&#8217;s some quick [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-1291","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-kP","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=1291"}],"version-history":[{"count":6,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1291\/revisions"}],"predecessor-version":[{"id":1300,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/1291\/revisions\/1300"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=1291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=1291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=1291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}