DUE BrainBot Dance

DUE BrainBot Dance

Now it’s time to give our BrainBot life! This first lesson will show us how to move our BrainBot.


This lesson assumes you’ve already BrainBot Assembled the BrainBot and read the BrainBot Intro.


This function doesn’t really need explaining and doesn’t take any arguments.


To move the BrainBot, we’ll use the Move() function. It uses L and R variablesfor left and right motor speeds. The range of these values are -100 to 100. With these two arguments we can move the BrainBot in any direction and turn.

Let’s start by moving our robot forward. To achieve this, we would set both motor speed values the same. This will make both wheels spin the same. Let’s start a speed of 40.

Print("I'm Alive")
L = 40
R = 40

Moving Backwards

Can you guess how we would make the BrainBot move backwards? If you guessed use negative numbers, you would be correct! Let’s try this.

Print("I'm moving backwards")


To turn the BrainBot, we use the exact same Move() function. This time, however, we only turn one wheel will while not turning the other wheel at all. Let’s make the BrainBot move forward for a short distance and then turn to the right. We’ll need to Wait() for a bit in between each Move() function call.

Note how Wait() is not commanding the robot to wait. Instead, it is for the BrainPad to wait before it tells the robot what to do next.

Goto Loop

You may have noticed or tried to get the BrainBot to drive in a perfect square. This isn’t really possible with the simple code we’ve created. Also, more sensors are needed to detect the actual speed. There are many sensors that make autonomous vehicles possible. We’ll use the on-board sensors to control the movement of the BrainBot even better in later lessons.

Why do you think our 2 Wait() functions have different durations? Try playing with them to observe how the BrainBot responds.


If we wanted to make our BrainBot spin or turn very quickly, how do you think we could achieve this? We can do it all with the exact same Move() function and just make both wheels spin in opposite directions.

Print("I am spinning!")
L = -40
R = 40

How would we make the robot spin in the opposite direction? Try making it spin one direction for 2 seconds and then spin in the other direction.

What’s Next?

Now that we know how to move the BrainBot, let’s get it flashy!


Do we see now how complex programming a robot can be? Think about different types of robots used in the world. Some might only have to perform one simple task while others may do many things.

Content Licensing

Twitter Feed
Hot off the press!