https://bricks.stackexchange.com/questions/17587/can-lego-city-powered-up-trains-be-automated Stack Exchange Network Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange [ ] Loading... 1. + Tour Start here for a quick overview of the site + Help Center Detailed answers to any questions you might have + Meta Discuss the workings and policies of this site + About Us Learn more about Stack Overflow the company + Business Learn more about our products 2. 3. current community + Bricks help chat + Bricks Meta your communities Sign up or log in to customize your list. more stack exchange communities company blog 4. 5. Log in 6. Sign up Bricks is a question and answer site for LEGO(r) and building block enthusiasts. It only takes a minute to sign up. Sign up to join this community [ano] Anybody can ask a question [ano] Anybody can answer [an] The best answers are voted up and rise to the top Bricks 1. Home 2. 1. Public 2. Questions 3. Tags 4. Users 5. Unanswered 3. 1. Teams Stack Overflow for Teams - Start collaborating and sharing organizational knowledge. [teams-illo-free-si] Create a free Team Why Teams? 2. Teams 3. Create free Team Stack Overflow for Teams is moving to its own domain! When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on stackoverflow.com. Check your email for updates. Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams Can LEGO City Powered Up trains be automated? Ask Question Asked yesterday Modified today Viewed 22k times 23 I have a LEGO City train set (60336): 60336 Box The set includes a remote control as well as an app that can be used to control the train. Is it possible to automate the operation of LEGO City trains, ideally without needing to be tethered to a smart device to help reduce children getting distracted by a screen? * trains * powered-up Share Improve this question Follow edited 4 hours ago jncraton asked yesterday jncraton's user avatar jncratonjncraton 35.5k1010 gold badges104104 silver badges207207 bronze badges Add a comment | 1 Answer 1 Sorted by: Reset to default [Highest score (default) ] 27 I've been exploring this recently, and I wanted to share my experiences in the hopes that they are useful to others. There are a few ways this can be accomplished. Some are possible out of the box, and others require extra hardware or 3rd-party software. Typical Package Contents Here's the electronics we typically get out of the box with a Powered Up train set: 1. Powered Up City hub (28738). This includes two I/O ports (used for a motor and possibly lights). The City hub does not include an accelerometer, compass, or GPS, so there is limited feedback provided. It does include a programmable RGB LED and a button. City Hub 2. Train Motor (28740). This motor is one of only two Powered Up motors that do not include rotation and distance tracking, so there is no easy way to know how far the train has traveled, but we are able to adjust its relative speed. Train motor 3. Lights (22168) may be included as headlights for the train. Lights Programming using Powered Up App The default experience in the Powered Up app provides a controller for the train, but we can also automate the train using a Scratch-like programming environment. This environment is powerful, but the hardware at our disposal is quite limited as a robotics platform. In particular, the included hardware has no useful sensors, which makes the environment unobservable. If we start the train from a known location, we can run it at a set approximate speed for a certain amount of time, leaving it at a new approximate location. Unfortunately, these locations will change slightly over time, as we have no way of sensing exactly far we have traveled. This might be fine if you just want the train to move for a while then stop for a while, but if you want to stop at stations, things get trickier. One solution is to induce the train to stop at a known location regularly, such as a siding. We can intentionally stall against the buffer on the siding to reset to a known position. Adding Sensors If we're willing to add some additional hardware, things can get much more advanced. One option is to add a color sensor to the bottom on the train: Step 1 We can connect the sensor to the port not being used by the motor. Step 2 Step 3 With this in place, we can modify our track by adding plates or tiles of different colors to indicate location on the track or particular actions to take. In this way, we can have the train reliably stop at stations or take other actions. Here's an example program that allows the train to wait when it sees red under the color sensor: Program screenshot This is similar in concept to the DUPLO trains in terms of input, but we can program the colors to change behaviors in any way we'd like. We could also choose to add a different sensor, such as a distance sensor or a tilt sensor. Alternatively, we could replace the City hub with a larger hub and add multiple sensors, but this would likely require redesigning the train and would add significant cost. Standalone Operation One of the weaknesses of the City Hub currently is that it requires a tethered Bluetooth device, such as a phone, tablet or computer, in order to function. By flashing the custom Pybricks firmware to the hub, we can overcome this limitation and write programs directly to the device. This is especially useful for public displays or other use cases where Bluetooth connections may become problematic. Here is an example Pybricks program that would allow a train to run for 10 seconds and then pause for 35 using the RGB LED on the hub to indicate its status: """ Simple automated train that runs for 10 seconds then pauses for 35 Light transitions from red to orange to yellow as timer counts down """ from pybricks.hubs import CityHub from pybricks.pupdevices import DCMotor, Light from pybricks.parameters import Button, Color, Direction, Port, Stop from pybricks.robotics import DriveBase from pybricks.tools import wait, StopWatch hub = CityHub() motor = DCMotor(Port.A) while True: hub.light.on(Color.GREEN) motor.dc(60) wait(10000) motor.dc(0) hub.light.on(Color.RED) wait(15000) hub.light.on(Color.ORANGE) wait(15000) hub.light.on(Color.YELLOW) wait(5000) I use a setup similar to the above to allow an automated train to run around my son's city without the need to have a screen nearby the whole time. Share Improve this answer Follow edited 4 hours ago David Lechner's user avatar David Lechner 8,9181515 silver badges5454 bronze badges answered yesterday jncraton's user avatar jncratonjncraton 35.5k1010 gold badges104104 silver badges207207 bronze badges Add a comment | Your Answer [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] Thanks for contributing an answer to Bricks! * Please be sure to answer the question. Provide details and share your research! But avoid ... * Asking for help, clarification, or responding to other answers. * Making statements based on opinion; back them up with references or personal experience. To learn more, see our tips on writing great answers. Draft saved Draft discarded [ ] Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Submit Post as a guest Name [ ] Email Required, but never shown [ ] Post as a guest Name [ ] Email Required, but never shown [ ] Post Your Answer Discard By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy Not the answer you're looking for? Browse other questions tagged * trains * powered-up or ask your own question. * Featured on Meta * Help us identify new roles for community members * Inbox improvements are live Related 7 How can the new LEGO pneumatics be used for trains? 1 Does my child need a smart device to control LEGO Powered Up train sets? 2 How many and what kind of batteries are needed for LEGO Powered Up? 6 Can several users control one Powered Up train using different devices? 6 Has anyone tried putting the Powered Up system in the Christmas train? 13 Multiple Powered Up trains on 1 Bluetooth controller? 5 Two LEGO Powered Up engines with reverse direction 1 Can two Powered Up train motors be plugged into one hub 8 Options for powering Winter Holiday Train 6 Train with two Powered Up hubs Hot Network Questions * How would amphibious cone-aliens have 150 feet of tongue? * Unable to Access USB Connected Device Storage Using Command Line * What d10 RPG is this cat playing? * Why is the Orion capsule using 2 burns to transfer from the moon back to earth instead of one? * One English noun for a gracious postponement of some required action * When did math start to be a hated subject in schools and universities? * How to define a custome gate from a matrix in TKET * How fast would supplies become rare in a post-electric world? * CGAC2022 Day 5: Preparing an advent calendar * Could a nomadic society survive on a planet with a year-long daylight cycle? * A property of even continuous functions on the sphere * How to prevent instances from changing positions during animation? * Can I omit my medium mount from an emanation? * Create Buffer but keep original Attribute table * EWR international to international * Looking for a SF short story told from a kitten's point of view * Bulk renaming files * Why is integer factoring hard while determining whether an integer is prime easy? * Masters' advisor uses my work without citing it - Journal decided to intervene * How was Aragorn's legitimacy as king verified? * Can you defame a profession? * Simplified formula for duration of interest rate swap * Likely cause of heater being stuck on? * Help for Staking Pallet! Preventing oversubscription on validator nodes more hot questions Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. [https://bricks.stack] * Bricks * Tour * Help * Chat * Contact * Feedback Company * Stack Overflow * Teams * Advertising * Collectives * Talent * About * Press * Legal * Privacy Policy * Terms of Service * Cookie Settings * Cookie Policy Stack Exchange Network * Technology * Culture & recreation * Life & arts * Science * Professional * Business * API * Data * Blog * Facebook * Twitter * LinkedIn * Instagram Site design / logo (c) 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2022.12.5.43077 LEGO(r) is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this site Your privacy By clicking "Accept all cookies", you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Accept all cookies Customize settings