First Programs: 3. Distance

The intelino train always tracks the distance it travels. When you connect the train to intelino Scratch and create a new program, it sets the distance to 0 and keeps track of it as you start driving the train. As shown in the image below, you can always see the current distance in the upper-right window by checking the box next to the distance block:

Add a drive block and click on it to get the train driving or just roll it on a track or a tabletop by hand. As long as the train is connected to Scratch, you'll see the distance start incrementing. This feature can be very useful whenever you'd like the train do something based on the distance travelled.

Let's use the when distance >= event block to create a very simple program that gets the train to always pause after some distance:

The drive block initiates the movement of the train. The when distance >= block always keeps track of the distance travelled and triggers the code below it the moment the distance exceeds the chosen value (50cm in this example). To make the train stop, we add the pause driving block. And we also reset the distance tracker back to 0 using the reset distance block (otherwise, after the first pause, the train would keep going and never stop again).

Put this program together and test it on a track of your choice. Don't forget that you need to click the drive block to get the train moving. But you can also initiate movement by a push start or with a short press of the power button - give it a try! 


For more Scratch program examples, please visit our intelino lab site.

Next Article: Scratch Programming Blocks Reference

Previous Article: First Programs: 2. Events

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us