{"id":68942,"date":"2022-11-26T09:00:58","date_gmt":"2022-11-26T09:00:58","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=68942"},"modified":"2022-11-26T09:00:58","modified_gmt":"2022-11-26T09:00:58","slug":"create-a-holiday-light-display-with-your-raspberry-pi-and-ping-pong-balls","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=68942","title":{"rendered":"Create a holiday light display with your Raspberry Pi and ping pong balls"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">Create a holiday light display with your Raspberry Pi and ping pong balls<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/bdm\" class=\"username\">Brian McCafferty<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Sat, 11\/26\/2022 &#8211; 03:00<\/span><\/p>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>I love Christmas decorations and lights, and I&#8217;d been wanting to do an programmable LED project for a long time. Recently, I built a light array made of LED lights, ping pong balls, and a Raspberry Pi Zero. I thought it was worth sharing, because it ended up being relatively easy but also educational.<\/p>\n<p>It&#8217;s mostly my own design, with some inspiration from YouTube videos. You can find the source code and build instructions in my <a href=\"https:\/\/github.com\/bmccafferty\/ping-pong-led-wall\">Git repository<\/a>.<\/p>\n<h2>Shopping list<\/h2>\n<ul>\n<li><a href=\"https:\/\/shop.pimoroni.com\/products\/raspberry-pi-zero-wh-with-pre-soldered-header\">Raspberry Pi Zero<\/a><\/li>\n<li><a href=\"https:\/\/shop.pimoroni.com\/products\/pibow-zero-w\">Pibow Case<\/a><\/li>\n<li>5v 2A USB power supply<\/li>\n<li>Poster frame<\/li>\n<li>255 ping pong balls<\/li>\n<li>Hot glue gun and LOTS of hot glue sticks<\/li>\n<li>Soldering iron<\/li>\n<li>Solder<\/li>\n<li><span class=\"a-size-large product-title-word-break\">22 AWG 0.35mm solid core wiring<\/span><\/li>\n<li>10 meters of WS2812(B) LED strip lights (30 pixels per meter)<\/li>\n<li>Multimeter<\/li>\n<li>Wire cutters<\/li>\n<li>Wire strippers<\/li>\n<\/ul>\n<h2>Design the Raspberry Pi light display<\/h2>\n<p>My design was driven by the size of the poster frame I happened to have available. I got 30 pixel per meter tape from Ali Express, which cut nicely into 0.5m sections, so that gave me 15 LEDs across. Ping pong balls are 40mm, so I measured and placed the lines 40mm apart, with the LED Strip in the middle of each 40mm section. This gave me 17 lines down in total. My array was therefore 15\u00d717. If you try this yourself, yours can be a different size.<\/p>\n<p>To get power to the array and the Raspberry Pi, I placed the open connections for both data and power at the bottom of the board. I didn&#8217;t have that many LEDs needing power, so I was able to use the 5v out GPIO from the Raspberry Pi Zero to power them. I run them at 50% brightness, which is easily bright enough to see in the day and at night through my window.<\/p>\n<h2>Wiring<\/h2>\n<p>In my design, I started at the bottom of the board and wired up in an S-curve. This made soldering easier because loops at the end of each row didn&#8217;t have to return all the way back to the start of each line. The WS2812 data lines do require you to wire the data the correct way: power can be fed from either side of the strip, but data must be fed from the side with the arrows pointing away.<\/p>\n<p>My wiring looks like this (this is abbreviated for clarity, in real life it&#8217;s 17 lines deep):<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"text geshifilter-text\">\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 |<br>\n\/---------------\/<br>\n|<br>\n---------------<\/div><h2>Build the display with your Raspberry Pi<\/h2>\n<p>Once the design and wiring plan was sorted, it was time to get started on the build.<\/p>\n<p>I measured and drew my lines in pencil on the poster backboard. The WS2812 strips I got came with sticky tape on the back, so I just removed the backing and attached that directly to the backboard. I was sure to position each strip so that the data arrows went one way, then back the other, to ensure that the lights could be daisy-chained correctly for the Pi's instructions.<\/p>\n<p>Once all light strips were attached, I cut three similar lengths of wire and connected the 5v, data, and ground lines from the end of each light section to the one above it.<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\"><div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/11\/IMG_20201126_115520.jpeg\" width=\"3840\" height=\"5120\" alt=\"Connect each light strip at the end of each line.\"><\/div>\n      \n   <div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><p>(Brian McCafferty, CC BY-SA 4.0)<\/p>\n<\/div>\n\n  <\/article><p><\/p><div class=\"embedded-resource-list callout-float-right\">\n            <div class=\"field field--name-title field--type-string field--label-hidden field__item\">More on Raspberry Pi<\/div>\n      \n      <div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n              <div class=\"field__item\"><a href=\"https:\/\/opensource.com\/resources\/what-raspberry-pi?intcmp=7016000000127cYAAQ\">What is Raspberry Pi?<\/a><\/div>\n              <div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/raspberry-pi-guide?intcmp=7016000000127cYAAQ\">eBook: Guide to Raspberry Pi<\/a><\/div>\n              <div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/getting-started-raspberry-pi-cheat-sheet?intcmp=7016000000127cYAAQ\">Getting started with Raspberry Pi cheat sheet<\/a><\/div>\n              <div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/kubernetes-raspberry-pi?intcmp=7016000000127cYAAQ\">eBook: Running Kubernetes on your Raspberry Pi<\/a><\/div>\n              <div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/resources\/data-intensive-applications-hybrid-cloud-blueprint-detail?intcmp=7016000000127cYAAQ\">Whitepaper: Data-intensive intelligent applications in a hybrid cloud blueprint<\/a><\/div>\n              <div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/topics\/edge-computing?intcmp=7016000000127cYAAQ\">Understanding edge computing<\/a><\/div>\n              <div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/raspberry-pi?intcmp=7016000000127cYAAQ\">Our latest on Raspberry Pi<\/a><\/div>\n          <\/div>\n  <\/div>\n<p>After completing each row, I checked continuity between the 5v and ground lines between each strip to ensure my joins were correct. I also checked that I had not accidentally bridged any connections, so I verified that there was no continuity between the 5v and ground lines (in other words, a 5v wire on one line didn't bridge to the ground on the next line.) I also ran some tests to ensure everything was lighting up correctly (see <a href=\"https:\/\/opensource.com\/#the-code\" target=\"_blank\" rel=\"noopener\">the code<\/a> section for my strand tests.)<\/p>\n<p>Once this was complete, I started to cut holes in the ping pong balls by stabbing scissors into the bottom of them, and cutting a small hole for the LED to shine into. There was no exact science to this, and each one was different, but the effect really worked. I was working with 30 pixels per meter, so my lighting had about 30mm between each LED. A ping pong ball is 40mm across, but I wasn't about to start soldering each LED individually! First of all, I'm not that good at soldering (as my photos show), and anyway, I thought \"Well, they're ping pong balls. I can just squash them together!\"<\/p>\n<p>And that's what I did.<\/p>\n<p>I placed a hot glue blob around each LED and then placed a ping pong ball onto the LED, held it for about five seconds, and moved on to the next one. I held onto the previous ping pong ball as I slid the next one in, pushing it against the first before \"folding\" it into its neighbor. The effect worked really well. I was happy with what it was looking like straight away. It also had the nice bonus of hiding my bad soldering job ;)<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\"><div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-11\/IMG_20201127_101409.webp\" width=\"1824\" height=\"1368\" alt=\"It's a tight fit, but the 40mm ping pong balls fit in a 30mm space just fine.\"><\/div>\n      \n   <div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><p>(Brian McCafferty, CC BY-SA 4.0)<\/p>\n<\/div>\n\n  <\/article><p>I continued doing this for 255 LEDs and ping pong balls. There were a few crushed ping pong balls in the process, but in the end, I got there.<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\"><div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-11\/IMG_20201127_160500.webp\" width=\"1368\" height=\"1824\" alt=\"255 LEDs and 255 ping pong balls in an array.\"><\/div>\n      \n   <div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><p>(Brian McCafferty, CC BY-SA 4.0)<\/p>\n<\/div>\n\n  <\/article><h2>Test the code<\/h2>\n<p>For the test code to ensure that everything was working, I used this <a href=\"https:\/\/learn.adafruit.com\/neopixels-on-raspberry-pi\/python-usage\">Adafruit guide<\/a>\u00a0which lights each LED in red, green, and blue, and then does a rainbow cycle. I used this when I was building to ensure my connections were correct and that everything was soldered correctly.<\/p>\n<p>After that, I designed a grid in a spreadsheet to map each pixel to a grid position. This helped to make building the images easier. Since my pixel numbers run in a zig-zag pattern, it would have been hard to keep track of each LED (e.g. LED A1 was 256 and B1 was 226).\u00a0<\/p>\n<p>Once this was all set, it was time to design some images on paper and in the spreadsheet. Then it was time to code! It got a bit addictive and I started adding some animation (using loops and turning pixels onto one color and then another color).\u00a0<\/p>\n<p>The end result was everything I'd hoped it would be.<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\"><div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-11\/IMG_20201127_181931.webp\" width=\"1368\" height=\"1824\" alt=\"A Christmas gift in LED.\"><\/div>\n      \n   <div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><p>(Brian McCafferty, CC BY-SA 4.0)<\/p>\n<\/div>\n\n  <\/article><article class=\"align-center media media--type-image media--view-mode-default\"><div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-11\/IMG_20201202_215902.webp\" width=\"1368\" height=\"1824\" alt=\"Reindeer painted with light.\"><\/div>\n      \n   <div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><p>(Brian McCafferty, CC BY-SA 4.0)<\/p>\n<\/div>\n\n  <\/article><article class=\"align-center media media--type-image media--view-mode-default\"><div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/opensource.com\/sites\/default\/files\/2022-11\/IMG_20201127_215314.webp\" width=\"1368\" height=\"1824\" alt=\"An LED snowflake.\"><\/div>\n      \n   <div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><p>(Brian McCafferty, CC BY-SA 4.0)<\/p>\n<\/div>\n\n  <\/article><h2>A Raspberry Pi light display all year<\/h2>\n<p>I am not sure this will ever be truly finished. Nearly every night since it's been up in the window, I've added some new images and animations. I'm already thinking about what to do for New Year's Eve. I also won't be putting this back in storage with my Christmas decorations in January. I just need to think of other things to draw on it to make it a year-round project! A friend of mine suggested a pixel Mario and I love that idea!<\/p>\n<p>My code also needs a little work. For example, I do some scrolling text, but I redraw the whole board for each position of the text, so it took quite a bit of time to do. I think I can do something with loops, or perhaps the image library can help scroll the letters easier, and make it easier to add text rather than turning each pixel on and off at every step.<\/p>\n<p>I've got a photo record of my progress from start to finish: <a href=\"https:\/\/projects.bdm.scot\/Xmas%20LED%20Wall%202020\/\">LED Ping Pong Wall<\/a>.<\/p>\n<p>You can also see a video of it in action here: <a href=\"https:\/\/youtu.be\/zc0501GzpMw\">XMas light display<\/a>.<\/p>\n<p>I'm really pleased with how this turned out, and I think it looks amazing. I'm very excited to try some other LED projects in the future. I encourage you to try a light array of your own even as your first project. It's easier than it looks!<\/p>\n<\/div>\n      \n            <div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\"><p>This Raspberry Pi tutorial for building a programmable LED light display is perfect for all skill levels.<\/p>\n<\/div>\n      \n            <div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\"><article class=\"media media--type-image media--view-mode-caption\"><div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/11\/life-raspberrypi_0.png\" width=\"520\" height=\"292\" alt=\"Raspberries with pi symbol overlay\" title=\"Raspberries with pi symbol overlay\"><\/div>\n      \n   <div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><p>Dwight Sipler on Flickr<\/p>\n<\/div>\n\n  <\/article><\/div>\n      \n      <div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n              <div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/raspberry-pi\" hreflang=\"en\">Raspberry Pi<\/a><\/div>\n          <\/div>\n  \n            <div class=\"hidden field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n      \n            <div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/11\/cc-by-sa--39.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n      <section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\"><div class=\"comments__count\">\n                  <div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?destination=\/feed&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n  <\/div>\n\n  \n  \n<\/section><\/pre>\n<\/div>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a holiday light display with your Raspberry Pi and ping pong balls Brian McCafferty Sat, 11\/26\/2022 &#8211; 03:00 I love Christmas decorations and lights, and I&#8217;d been wanting to do an programmable LED project for a long time. Recently, I built a light array made of LED lights, ping pong balls, and a Raspberry [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":68943,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-68942","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/68942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=68942"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/68942\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/68943"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}