<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672</link><pubDate>Thu, 19 Mar 2026 17:36:13 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1f3d69d7-2469-436c-a5ea-db6de69de9b7</guid><dc:creator>cstanton</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672#comments</comments><description>Current Revision posted to Documents by cstanton on 3/19/2026 5:36:13 PM&lt;br /&gt;
&lt;p&gt;&lt;span&gt;Lorraine hacks a Bluetooth-controlled LEGO train in this week&amp;rsquo;s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train&amp;rsquo;s movement. Lorraine&amp;#39;s project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik0"&gt;&lt;span&gt;Watch the Video&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=hgJ8ywYu6bY"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What happens when a Bluetooth-controlled LEGO train meets a maker&amp;#39;s imagination and a ceiling with just enough clearance? In this episode of &lt;em data-start="246" data-end="266"&gt;element14 Presents&lt;/em&gt;, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/7103.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivafhktq0" data-start="575" data-end="596"&gt;Design Intentions&lt;/h2&gt;
&lt;p data-start="598" data-end="1145"&gt;The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment&amp;mdash;all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.&lt;/p&gt;
&lt;p data-start="598" data-end="1145"&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/5050.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik1"&gt;Component Choices&lt;/h2&gt;
&lt;p&gt;The core controller is the Seeed Studio XIAO nRF52840 Sense board&amp;mdash;compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train&amp;#39;s windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train&amp;rsquo;s power supply to conserve energy.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/4454.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik2"&gt;Challenges and Code&lt;/h2&gt;
&lt;p&gt;One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train&amp;rsquo;s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot2a-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik3"&gt;Results!&lt;/h2&gt;
&lt;p&gt;Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot1-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivagiq8f6"&gt;Supporting Downloads and Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="https://community.element14.com/challenges-projects/element14-presents/m/files/150452"&gt;Episode 672 Resources&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1ivag6sfs5"&gt;Bill of Materials&lt;/h2&gt;
&lt;table class="e14-product-bom-main"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Product Name&lt;/th&gt;
&lt;th&gt;Manufacturer&lt;/th&gt;
&lt;th&gt;Quantity&lt;/th&gt;
&lt;th&gt;&lt;a id="e14-product-link-3513a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352,3769965,3517886&amp;nsku=55AK3430,52AJ5992,87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3513a'));" data-farnell="4060352,3769965,3517886" data-newark="55AK3430,52AJ5992,87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="102010469,MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Kit&lt;/a&gt; &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SEEED STUDIO SBC, XIAO nRF52840 Sense, ARM Cortex-M4, 256kB RAM, 2MB Flash, Bluetooth, USB-C&lt;/td&gt;
&lt;td&gt;SEEED STUDIO&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-01209" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352&amp;nsku=55AK3430&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('01209'));" data-farnell="4060352" data-newark="55AK3430" data-comoverride="" data-cmpoverride="" data-cpc="102010469" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT Servo Motor, Micro, 6 V, 0.17 N-m&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-3b8a5" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3769965&amp;nsku=52AJ5992&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3b8a5'));" data-farnell="3769965" data-newark="52AJ5992" data-comoverride="" data-cmpoverride="" data-cpc="MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT LED Strip, Digital, RGB, Weatherproof, 60 LED, 1m, BBC Micro:bit Boards&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-c8a01" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3517886&amp;nsku=87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('c8a01'));" data-farnell="3517886" data-newark="87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego train&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego track&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wood&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;LiDAR LD06 Module (Farnell&amp;nbsp;&lt;a id="e14-product-link-e94c9" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3517894&amp;nsku=87AH5877&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('e94c9'));" data-farnell="3517894" data-newark="87AH5877" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;stock a similar model from DFROBOT&lt;/a&gt; )&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: custom LEGO track, Bluetooth LEGO train, e14p_LU, home automation with LEGO, LEGO automation, NeoPixel LED train, seeed xiao, LIDAR sensor train, ceiling train setup, CircuitPython project, LEGO train modification, electronics maker project, LEGO train hack, element14 community project, DIY smart train, train distance sensing, friday_release&lt;/div&gt;
</description></item><item><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672/revision/6</link><pubDate>Mon, 07 Jul 2025 14:47:19 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1f3d69d7-2469-436c-a5ea-db6de69de9b7</guid><dc:creator>cstanton</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672#comments</comments><description>Revision 6 posted to Documents by cstanton on 7/7/2025 2:47:19 PM&lt;br /&gt;
&lt;p&gt;&lt;span&gt;Lorraine hacks a Bluetooth-controlled LEGO train in this week&amp;rsquo;s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train&amp;rsquo;s movement. Lorraine&amp;#39;s project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik0"&gt;&lt;span&gt;Watch the Video&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=hgJ8ywYu6bY"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What happens when a Bluetooth-controlled LEGO train meets a maker&amp;#39;s imagination and a ceiling with just enough clearance? In this episode of &lt;em data-start="246" data-end="266"&gt;element14 Presents&lt;/em&gt;, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/7103.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivafhktq0" data-start="575" data-end="596"&gt;Design Intentions&lt;/h2&gt;
&lt;p data-start="598" data-end="1145"&gt;The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment&amp;mdash;all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.&lt;/p&gt;
&lt;p data-start="598" data-end="1145"&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/5050.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik1"&gt;Component Choices&lt;/h2&gt;
&lt;p&gt;The core controller is the Seeed Studio XIAO nRF52840 Sense board&amp;mdash;compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train&amp;#39;s windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train&amp;rsquo;s power supply to conserve energy.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/4454.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik2"&gt;Challenges and Code&lt;/h2&gt;
&lt;p&gt;One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train&amp;rsquo;s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot2a-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik3"&gt;Results!&lt;/h2&gt;
&lt;p&gt;Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot1-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivagiq8f6"&gt;Supporting Downloads and Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="https://community.element14.com/challenges-projects/element14-presents/m/files/150452"&gt;Episode 672 Resources&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1ivag6sfs5"&gt;Bill of Materials&lt;/h2&gt;
&lt;table class="e14-product-bom-main"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Product Name&lt;/th&gt;
&lt;th&gt;Manufacturer&lt;/th&gt;
&lt;th&gt;Quantity&lt;/th&gt;
&lt;th&gt;&lt;a id="e14-product-link-90354" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352,3769965,3517886&amp;nsku=55AK3430,52AJ5992,87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('90354'));" data-farnell="4060352,3769965,3517886" data-newark="55AK3430,52AJ5992,87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="102010469,MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Kit&lt;/a&gt; &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SEEED STUDIO SBC, XIAO nRF52840 Sense, ARM Cortex-M4, 256kB RAM, 2MB Flash, Bluetooth, USB-C&lt;/td&gt;
&lt;td&gt;SEEED STUDIO&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-09e6a" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352&amp;nsku=55AK3430&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('09e6a'));" data-farnell="4060352" data-newark="55AK3430" data-comoverride="" data-cmpoverride="" data-cpc="102010469" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT Servo Motor, Micro, 6 V, 0.17 N-m&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-b148c" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3769965&amp;nsku=52AJ5992&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('b148c'));" data-farnell="3769965" data-newark="52AJ5992" data-comoverride="" data-cmpoverride="" data-cpc="MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT LED Strip, Digital, RGB, Weatherproof, 60 LED, 1m, BBC Micro:bit Boards&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-99cbd" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3517886&amp;nsku=87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('99cbd'));" data-farnell="3517886" data-newark="87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego train&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego track&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wood&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;nbsp;LiDAR LD06 Module (Farnell&amp;nbsp;&lt;a id="e14-product-link-17a65" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3517894&amp;nsku=87AH5877&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('17a65'));" data-farnell="3517894" data-newark="87AH5877" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;stock a similar model from DFROBOT&lt;/a&gt; )&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: custom LEGO track, Bluetooth LEGO train, home automation with LEGO, LEGO automation, NeoPixel LED train, seeed xiao, LIDAR sensor train, ceiling train setup, CircuitPython project, LEGO train modification, electronics maker project, LEGO train hack, element14 community project, DIY smart train, train distance sensing, friday_release&lt;/div&gt;
</description></item><item><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672/revision/5</link><pubDate>Mon, 07 Jul 2025 14:43:34 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1f3d69d7-2469-436c-a5ea-db6de69de9b7</guid><dc:creator>cstanton</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672#comments</comments><description>Revision 5 posted to Documents by cstanton on 7/7/2025 2:43:34 PM&lt;br /&gt;
&lt;p&gt;&lt;span&gt;Lorraine hacks a Bluetooth-controlled LEGO train in this week&amp;rsquo;s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train&amp;rsquo;s movement. Lorraine&amp;#39;s project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik0"&gt;&lt;span&gt;Watch the Video&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=hgJ8ywYu6bY"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What happens when a Bluetooth-controlled LEGO train meets a maker&amp;#39;s imagination and a ceiling with just enough clearance? In this episode of &lt;em data-start="246" data-end="266"&gt;element14 Presents&lt;/em&gt;, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/7103.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivafhktq0" data-start="575" data-end="596"&gt;Design Intentions&lt;/h2&gt;
&lt;p data-start="598" data-end="1145"&gt;The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment&amp;mdash;all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.&lt;/p&gt;
&lt;p data-start="598" data-end="1145"&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/5050.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik1"&gt;Component Choices&lt;/h2&gt;
&lt;p&gt;The core controller is the Seeed Studio XIAO nRF52840 Sense board&amp;mdash;compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train&amp;#39;s windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train&amp;rsquo;s power supply to conserve energy.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/4454.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik2"&gt;Challenges and Code&lt;/h2&gt;
&lt;p&gt;One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train&amp;rsquo;s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot2a-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik3"&gt;Results!&lt;/h2&gt;
&lt;p&gt;Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot1-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivagiq8f6"&gt;Supporting Downloads and Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="https://community.element14.com/challenges-projects/element14-presents/m/files/150452"&gt;Episode 672 Resources&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1ivag6sfs5"&gt;Bill of Materials&lt;/h2&gt;
&lt;table class="e14-product-bom-main"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Product Name&lt;/th&gt;
&lt;th&gt;Manufacturer&lt;/th&gt;
&lt;th&gt;Quantity&lt;/th&gt;
&lt;th&gt;&lt;a id="e14-product-link-13ac7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352,3769965,3517886&amp;nsku=55AK3430,52AJ5992,87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('13ac7'));" data-farnell="4060352,3769965,3517886" data-newark="55AK3430,52AJ5992,87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="102010469,MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Kit&lt;/a&gt; &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SEEED STUDIO SBC, XIAO nRF52840 Sense, ARM Cortex-M4, 256kB RAM, 2MB Flash, Bluetooth, USB-C&lt;/td&gt;
&lt;td&gt;SEEED STUDIO&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-77f51" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352&amp;nsku=55AK3430&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('77f51'));" data-farnell="4060352" data-newark="55AK3430" data-comoverride="" data-cmpoverride="" data-cpc="102010469" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT Servo Motor, Micro, 6 V, 0.17 N-m&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-f5c6d" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3769965&amp;nsku=52AJ5992&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('f5c6d'));" data-farnell="3769965" data-newark="52AJ5992" data-comoverride="" data-cmpoverride="" data-cpc="MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT LED Strip, Digital, RGB, Weatherproof, 60 LED, 1m, BBC Micro:bit Boards&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-25968" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3517886&amp;nsku=87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('25968'));" data-farnell="3517886" data-newark="87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego train&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego track&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wood&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="xs-hide"&gt;
&lt;td&gt;&amp;nbsp;LiDAR LD06 Module (Farnell&amp;nbsp;&lt;a id="e14-product-link-07af1" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3517894&amp;nsku=87AH5877&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('07af1'));" data-farnell="3517894" data-newark="87AH5877" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;stock a similar model from DFROBOT&lt;/a&gt; )&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: custom LEGO track, Bluetooth LEGO train, home automation with LEGO, LEGO automation, NeoPixel LED train, seeed xiao, LIDAR sensor train, ceiling train setup, CircuitPython project, LEGO train modification, electronics maker project, LEGO train hack, element14 community project, DIY smart train, train distance sensing, friday_release&lt;/div&gt;
</description></item><item><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672/revision/4</link><pubDate>Mon, 07 Jul 2025 14:42:56 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1f3d69d7-2469-436c-a5ea-db6de69de9b7</guid><dc:creator>cstanton</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672#comments</comments><description>Revision 4 posted to Documents by cstanton on 7/7/2025 2:42:56 PM&lt;br /&gt;
&lt;p&gt;&lt;span&gt;Lorraine hacks a Bluetooth-controlled LEGO train in this week&amp;rsquo;s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train&amp;rsquo;s movement. Lorraine&amp;#39;s project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik0"&gt;&lt;span&gt;Watch the Video&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=hgJ8ywYu6bY"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What happens when a Bluetooth-controlled LEGO train meets a maker&amp;#39;s imagination and a ceiling with just enough clearance? In this episode of &lt;em data-start="246" data-end="266"&gt;element14 Presents&lt;/em&gt;, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/7103.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivafhktq0" data-start="575" data-end="596"&gt;Design Intentions&lt;/h2&gt;
&lt;p data-start="598" data-end="1145"&gt;The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment&amp;mdash;all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.&lt;/p&gt;
&lt;p data-start="598" data-end="1145"&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/5050.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik1"&gt;Component Choices&lt;/h2&gt;
&lt;p&gt;The core controller is the Seeed Studio XIAO nRF52840 Sense board&amp;mdash;compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train&amp;#39;s windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train&amp;rsquo;s power supply to conserve energy.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/4454.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik2"&gt;Challenges and Code&lt;/h2&gt;
&lt;p&gt;One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train&amp;rsquo;s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot2a-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik3"&gt;Results!&lt;/h2&gt;
&lt;p&gt;Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot1-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivagiq8f6"&gt;Supporting Downloads and Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="https://community.element14.com/challenges-projects/element14-presents/m/files/150452"&gt;Episode 672 Resources&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1ivag6sfs5"&gt;Bill of Materials&lt;/h2&gt;
&lt;table class="e14-product-bom-main"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Product Name&lt;/th&gt;
&lt;th&gt;Manufacturer&lt;/th&gt;
&lt;th&gt;Quantity&lt;/th&gt;
&lt;th&gt;&lt;a id="e14-product-link-d4de0" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352,3769965,3517886&amp;nsku=55AK3430,52AJ5992,87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('d4de0'));" data-farnell="4060352,3769965,3517886" data-newark="55AK3430,52AJ5992,87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="102010469,MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Kit&lt;/a&gt; &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SEEED STUDIO SBC, XIAO nRF52840 Sense, ARM Cortex-M4, 256kB RAM, 2MB Flash, Bluetooth, USB-C&lt;/td&gt;
&lt;td&gt;SEEED STUDIO&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-ff458" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352&amp;nsku=55AK3430&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('ff458'));" data-farnell="4060352" data-newark="55AK3430" data-comoverride="" data-cmpoverride="" data-cpc="102010469" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT Servo Motor, Micro, 6 V, 0.17 N-m&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-167b6" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3769965&amp;nsku=52AJ5992&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('167b6'));" data-farnell="3769965" data-newark="52AJ5992" data-comoverride="" data-cmpoverride="" data-cpc="MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT LED Strip, Digital, RGB, Weatherproof, 60 LED, 1m, BBC Micro:bit Boards&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-483a6" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3517886&amp;nsku=87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('483a6'));" data-farnell="3517886" data-newark="87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego train&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego track&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wood&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="xs-hide"&gt;
&lt;td&gt;&amp;nbsp;LiDAR LD06 Module (Farnell &lt;a id="e14-product-link-3a57b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="link" href="https://referral.element14.com/OrderCodeView?fsku=3517894&amp;nsku=87AH5877&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-link" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('3a57b'));" data-farnell="3517894" data-newark="87AH5877" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;stock a similar model from DFROBOT&lt;/a&gt; )&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: custom LEGO track, Bluetooth LEGO train, home automation with LEGO, LEGO automation, NeoPixel LED train, seeed xiao, LIDAR sensor train, ceiling train setup, CircuitPython project, LEGO train modification, electronics maker project, LEGO train hack, element14 community project, DIY smart train, train distance sensing, friday_release&lt;/div&gt;
</description></item><item><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672/revision/2</link><pubDate>Fri, 04 Jul 2025 10:47:33 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1f3d69d7-2469-436c-a5ea-db6de69de9b7</guid><dc:creator>cstanton</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672#comments</comments><description>Revision 2 posted to Documents by cstanton on 7/4/2025 10:47:33 AM&lt;br /&gt;
&lt;p&gt;&lt;span&gt;Lorraine hacks a Bluetooth-controlled LEGO train in this week&amp;rsquo;s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train&amp;rsquo;s movement. Lorraine&amp;#39;s project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik0"&gt;&lt;span&gt;Watch the Video&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=hgJ8ywYu6bY"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What happens when a Bluetooth-controlled LEGO train meets a maker&amp;#39;s imagination and a ceiling with just enough clearance? In this episode of &lt;em data-start="246" data-end="266"&gt;element14 Presents&lt;/em&gt;, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-04-35/7103.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivafhktq0" data-start="575" data-end="596"&gt;Design Intentions&lt;/h2&gt;
&lt;p data-start="598" data-end="1145"&gt;The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment&amp;mdash;all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.&lt;/p&gt;
&lt;p data-start="598" data-end="1145"&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-04-35/5050.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik1"&gt;Component Choices&lt;/h2&gt;
&lt;p&gt;The core controller is the Seeed Studio XIAO nRF52840 Sense board&amp;mdash;compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train&amp;#39;s windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train&amp;rsquo;s power supply to conserve energy.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-04-35/4454.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik2"&gt;Challenges and Code&lt;/h2&gt;
&lt;p&gt;One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train&amp;rsquo;s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-04-35/shot2a-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik3"&gt;Results!&lt;/h2&gt;
&lt;p&gt;Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-04-35/shot1-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivagiq8f6"&gt;Supporting Downloads and Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="https://community.element14.com/challenges-projects/element14-presents/m/files/150452"&gt;Episode 672 Resources&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1ivag6sfs5"&gt;Bill of Materials&lt;/h2&gt;
&lt;table class="e14-product-bom-main"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Product Name&lt;/th&gt;
&lt;th&gt;Manufacturer&lt;/th&gt;
&lt;th&gt;Quantity&lt;/th&gt;
&lt;th&gt;&lt;a id="e14-product-link-87b23" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352,3769965,3517886&amp;nsku=55AK3430,52AJ5992,87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('87b23'));" data-farnell="4060352,3769965,3517886" data-newark="55AK3430,52AJ5992,87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="102010469,MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Kit&lt;/a&gt; &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SEEED STUDIO SBC, XIAO nRF52840 Sense, ARM Cortex-M4, 256kB RAM, 2MB Flash, Bluetooth, USB-C&lt;/td&gt;
&lt;td&gt;SEEED STUDIO&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-409d3" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352&amp;nsku=55AK3430&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('409d3'));" data-farnell="4060352" data-newark="55AK3430" data-comoverride="" data-cmpoverride="" data-cpc="102010469" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT Servo Motor, Micro, 6 V, 0.17 N-m&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-196e7" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3769965&amp;nsku=52AJ5992&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('196e7'));" data-farnell="3769965" data-newark="52AJ5992" data-comoverride="" data-cmpoverride="" data-cpc="MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT LED Strip, Digital, RGB, Weatherproof, 60 LED, 1m, BBC Micro:bit Boards&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-eb3aa" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3517886&amp;nsku=87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('eb3aa'));" data-farnell="3517886" data-newark="87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego train&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego track&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wood&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="xs-hide"&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: custom LEGO track, Bluetooth LEGO train, home automation with LEGO, LEGO automation, NeoPixel LED train, seeed xiao, LIDAR sensor train, ceiling train setup, CircuitPython project, LEGO train modification, electronics maker project, LEGO train hack, element14 community project, DIY smart train, train distance sensing, friday_release&lt;/div&gt;
</description></item><item><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672/revision/3</link><pubDate>Fri, 04 Jul 2025 10:47:33 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1f3d69d7-2469-436c-a5ea-db6de69de9b7</guid><dc:creator>e14sbhargav</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672#comments</comments><description>Revision 3 posted to Documents by e14sbhargav on 7/4/2025 10:47:33 AM&lt;br /&gt;
&lt;p&gt;&lt;span&gt;Lorraine hacks a Bluetooth-controlled LEGO train in this week&amp;rsquo;s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train&amp;rsquo;s movement. Lorraine&amp;#39;s project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik0"&gt;&lt;span&gt;Watch the Video&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=hgJ8ywYu6bY"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What happens when a Bluetooth-controlled LEGO train meets a maker&amp;#39;s imagination and a ceiling with just enough clearance? In this episode of &lt;em data-start="246" data-end="266"&gt;element14 Presents&lt;/em&gt;, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/7103.jpg" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivafhktq0" data-start="575" data-end="596"&gt;Design Intentions&lt;/h2&gt;
&lt;p data-start="598" data-end="1145"&gt;The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment&amp;mdash;all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.&lt;/p&gt;
&lt;p data-start="598" data-end="1145"&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/5050.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik1"&gt;Component Choices&lt;/h2&gt;
&lt;p&gt;The core controller is the Seeed Studio XIAO nRF52840 Sense board&amp;mdash;compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train&amp;#39;s windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train&amp;rsquo;s power supply to conserve energy.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/4454.jpg" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik2"&gt;Challenges and Code&lt;/h2&gt;
&lt;p&gt;One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train&amp;rsquo;s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot2a-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivag5jik3"&gt;Results!&lt;/h2&gt;
&lt;p&gt;Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" alt="image" style="max-height:360px;max-width:640px;"  src="/resized-image/__size/1280x720/__key/communityserver-wikis-components-files/00-00-00-03-81/shot1-Lorraine.png" /&gt;&lt;/p&gt;
&lt;h2 id="mcetoc_1ivagiq8f6"&gt;Supporting Downloads and Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="https://community.element14.com/challenges-projects/element14-presents/m/files/150452"&gt;Episode 672 Resources&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="mcetoc_1ivag6sfs5"&gt;Bill of Materials&lt;/h2&gt;
&lt;table class="e14-product-bom-main"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;Product Name&lt;/th&gt;
&lt;th&gt;Manufacturer&lt;/th&gt;
&lt;th&gt;Quantity&lt;/th&gt;
&lt;th&gt;&lt;a id="e14-product-link-8cc58" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352,3769965,3517886&amp;nsku=55AK3430,52AJ5992,87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_BUY_KIT" class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('8cc58'));" data-farnell="4060352,3769965,3517886" data-newark="55AK3430,52AJ5992,87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="102010469,MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Kit&lt;/a&gt; &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SEEED STUDIO SBC, XIAO nRF52840 Sense, ARM Cortex-M4, 256kB RAM, 2MB Flash, Bluetooth, USB-C&lt;/td&gt;
&lt;td&gt;SEEED STUDIO&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-6dfaa" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=4060352&amp;nsku=55AK3430&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('6dfaa'));" data-farnell="4060352" data-newark="55AK3430" data-comoverride="" data-cmpoverride="" data-cpc="102010469" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT Servo Motor, Micro, 6 V, 0.17 N-m&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-36d48" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3769965&amp;nsku=52AJ5992&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('36d48'));" data-farnell="3769965" data-newark="52AJ5992" data-comoverride="" data-cmpoverride="" data-cpc="MC02887" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DFROBOT LED Strip, Digital, RGB, Weatherproof, 60 LED, 1m, BBC Micro:bit Boards&lt;/td&gt;
&lt;td&gt;DFROBOT&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;a id="e14-product-link-07b6b" data-at-areainteracted="rte-content" data-at-type="click" data-at-link-type="button" href="https://referral.element14.com/OrderCodeView?fsku=3517886&amp;nsku=87AH5934&amp;COM=e14c-noscript&amp;CMP=e14c-noscript&amp;osetc=e14-noscript-tracking-loss" data-at-label="PRODUCT_POPUP_OPEN"class="e14-embedded e14_shopping-cart-far e14-button" onclick="event.preventDefault();e14.func.displayProduct(e14.meta.user.country, this, 'embedded-link', e14.func.getProductLinkJSON('07b6b'));" data-farnell="3517886" data-newark="87AH5934" data-comoverride="" data-cmpoverride="" data-cpc="" data-avnetemea="" data-avnetema="" data-avnetasia="" &gt;Buy Now&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego train&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lego track&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wood&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class="xs-hide"&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: custom LEGO track, Bluetooth LEGO train, home automation with LEGO, LEGO automation, NeoPixel LED train, seeed xiao, LIDAR sensor train, ceiling train setup, CircuitPython project, LEGO train modification, electronics maker project, LEGO train hack, element14 community project, DIY smart train, train distance sensing, friday_release&lt;/div&gt;
</description></item><item><title>Building an Autonomous LEGO Train with CircuitPython and LIDAR -- Episode 672</title><link>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672/revision/1</link><pubDate>Fri, 04 Jul 2025 10:26:36 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:1f3d69d7-2469-436c-a5ea-db6de69de9b7</guid><dc:creator>cstanton</dc:creator><comments>https://community.element14.com/challenges-projects/element14-presents/project-videos/w/documents/71936/building-an-autonomous-lego-train-with-circuitpython-and-lidar----episode-672#comments</comments><description>Revision 1 posted to Documents by cstanton on 7/4/2025 10:26:36 AM&lt;br /&gt;
&lt;p&gt;&lt;span&gt;Lorraine hacks a Bluetooth-controlled LEGO train in this week&amp;rsquo;s episode of element14 Presents, mounting a track system to the ceiling of her home. She integrates CircuitPython, a Seeed XIAO board, NeoPixels, and a spinning LIDAR sensor to detect walls and control the train&amp;rsquo;s movement. Lorraine&amp;#39;s project covers setup, track planning, component integration, and a ground-level test before moving the build to its final ceiling-mounted location. Watch to see how it performs!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Watch the Video&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.youtube.com/watch?v=hgJ8ywYu6bY"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What happens when a Bluetooth-controlled LEGO train meets a maker&amp;#39;s imagination and a ceiling with just enough clearance? In this episode of &lt;em data-start="246" data-end="266"&gt;element14 Presents&lt;/em&gt;, Lorraine takes on the challenge of modifying a standard LEGO train to follow custom commands, detect obstacles, and operate on an overhead track. The result is a creative blend of electronics, coding, and home decor, designed to move a train through the airspace of a living room using smart control.&lt;/span&gt;&lt;/p&gt;
&lt;h3 id="mcetoc_1ivafhktq0" data-start="575" data-end="596"&gt;Design Intentions&lt;/h3&gt;
&lt;p data-start="598" data-end="1145"&gt;The project began with a clear goal: to control the LEGO train programmatically and free it from its default Bluetooth remote. Rather than having the train occupy floor or shelf space, Lorraine designed a track layout to mount along two walls at ceiling level. The vision was to have the train run at set intervals, detect walls, and respond to its environment&amp;mdash;all without manual input. This required integrating control logic, sensing capabilities, and a power-conscious hardware setup, all embedded within the constraints of a moving LEGO train.&lt;/p&gt;
&lt;p&gt;Component Choices&lt;br /&gt;The core controller is the Seeed Studio XIAO nRF52840 Sense board&amp;mdash;compact, Bluetooth-enabled, and compatible with CircuitPython. It was small enough to fit inside a LEGO train carriage while providing the computing power needed for real-time control. A NeoPixel RGB LED strip was used to light up the train&amp;#39;s windows with programmable color effects. For obstacle detection, a rotating LIDAR sensor was mounted on top of the train. Although a simpler ultrasonic setup could have sufficed, the LIDAR offered wider coverage and visual appeal. A separate battery setup powered the XIAO, with an optional servo mechanism considered for toggling the train&amp;rsquo;s power supply to conserve energy.&lt;/p&gt;
&lt;p&gt;Challenges and Code&lt;br /&gt;One of the primary challenges was managing power consumption. The LIDAR sensor in particular drew significant power, raising concerns about the available battery life. While a servo was considered for turning off the train&amp;rsquo;s main battery to conserve energy, it would also consume power and possibly reduce overall efficiency. The code was developed in CircuitPython using libraries for NeoPixel control and serial communication. Existing Python code examples were adapted to work with CircuitPython, removing unnecessary features like data plotting and focusing on extracting distance values to detect when the train should stop.&lt;/p&gt;
&lt;p&gt;Results!&lt;br /&gt;Initial testing was carried out on a dining room table with curved LEGO track sections to simulate ceiling conditions. The train ran successfully, with LEDs illuminating the interior and the LIDAR detecting nearby walls and stopping the train appropriately. Some adjustments are still needed for cornering behavior and battery optimization, but the system is functional and ready for final installation on the ceiling. This project demonstrates how off-the-shelf LEGO hardware can be enhanced using microcontrollers and sensors to create a smart, interactive home feature.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>