TurtleBlock Studio

Build a robot car with blocks

Free ($0) is the block builder and the Pico W simulator. Standard ($30/month) adds ESP32, Raspberry Pi, Makeblock, USB upload, and .py downloads. Premium ($50/month) adds online project saves.

TurtleBlock Studio can drive a motor and turn a servo with blocks. A speed from -100 to 100 tells a DC motor to go one way, the other way, or stop. A servo block sets an angle from 0 to 180 degrees. The browser does not drive the car by itself. You try the idea on the Pico W simulator, then run it on a real board when you are ready.

What the studio can move

The DC motor block says DC motor IN1 pin, IN2 pin, and speed. Speed is a number from -100 to 100. A positive number drives one way. A negative number drives the other way. Zero stops. If you plug in a variable and forget to set it, the block treats that variable as 0, so the motor stays stopped.

The Motor Forward & Reverse sample is the starter. Its tips say to connect motor driver IN1 to GP10 and IN2 to GP11. The blocks in that sample use speed 80, wait 2000 milliseconds, speed 0, wait 500 milliseconds, then speed 80 and a stop again. The title says reverse, and the motor block can reverse, but those loaded numbers are 80 and 0. To go backward, change one speed to a negative number such as -80.

Turning is a different block. Servo pin set angle moves a servo from 0 to 180 degrees. The Full Police Car Command Lights sample is a later project. It uses a steering servo on GP3. The letter l moves that servo to 45 degrees, r moves it to 135, and stop centers it at 90. The drive motor in that sample uses IN1 GP19 and IN2 GP18.

  1. Press Open Studio and leave the board on Raspberry Pi Pico W. No account is needed.

  2. Open Samples, choose the Motors group, and open Motor Forward & Reverse.

  3. Look at the motor blocks. IN1 is GP10 and IN2 is GP11. The speeds in the sample are 80 and 0.

  4. Press Simulate, then Run Blocks. The terminal lists lines like [motor] IN1 GP10, IN2 GP11, speed 80%. The Virtual Motor card starts mapped to those same pins and shows FORWARD, REVERSE, or STOPPED plus a speed percent.

  5. Change one 80 to -80 and run the simulator again. A negative speed is the reverse direction. The log shows the negative number.

  6. Add a servo block on a free pin, for example GP3, and set the angle to 45, then 90, then 135. Run Blocks again. The terminal lists [servo] and the angle. That is the turn.

  7. On a real Pico W, use Chrome or Edge, plug in the board, and press Connect Board. An adult should wire the motor driver. The web page does not spin the wheels by itself.

MicroPython a motor speed of 80 creates

motor_in1 = PWM(Pin(10))
motor_in2 = PWM(Pin(11))
motor_in1.freq(1000)
motor_in2.freq(1000)
_motor_speed = 80
if _motor_speed >= 0:
    motor_in1.duty_u16(int(_motor_speed * 65535 / 100))
    motor_in2.duty_u16(0)
else:
    motor_in1.duty_u16(0)
    motor_in2.duty_u16(int(abs(_motor_speed) * 65535 / 100))

Read the speed before you run a real motor

The if line checks the speed. When the number is 0 or higher, the first pin gets the power and the second pin stays off. When the number is below 0, the pins swap, which is reverse. The studio limits the idea of speed to -100 through 100 on the block. Start with a small number such as 30 when a real motor is attached. The sample uses 80, which is a strong classroom demo, so read it before you connect wheels.

The simulator does not show a picture of a car driving across the screen. It shows pin levels, the Virtual Motor words, and the terminal log. Delays are logged as simulated time. They do not make you wait the full two seconds. The run stops after a long chain of steps, so the card shows the motor state from that run, not a forever animation.

Makeblock is a different path. If you pick Makeblock (Auriga on Python Host), the same motor block is rewritten as set_drive, which sends one speed to the right and left drive slots together. That mapping does not steer. Use the Makeblock guide for the Auriga. Use this page for a Pico W motor and a servo.

Pins from the samples

Motor Forward & Reverse uses IN1 GP10 and IN2 GP11. The police-car sample, when you want a bigger project, uses motor IN1 GP19, IN2 GP18, and steering servo GP3. Its tips also list the light pins.

Add a distance sensor only when you want the extra block. The motor sample tips say you can add one to stop when something is in the way. That is a sample tip, not a car that avoids walls by itself.

Common questions

Will the car drive from the browser?

No. The Pico W simulator shows a virtual motor. A real Pico W or ESP32 needs USB in Chrome or Edge and a motor driver an adult wires. Makeblock Python is copy-and-run on a computer. The website does not sign in to the robot.

How do I turn?

Use the servo block. Angle 90 is a useful center. The police-car sample uses 45 and 135 on GP3 for the two turn directions. There is not a single block named Turn the car.

Why does the sample say reverse but use 80?

The loaded Motor Forward & Reverse blocks use speed 80 and speed 0. The motor block reverses when the speed is negative. Change a speed to -80 to see REVERSE on the virtual motor.

Can I try this with no robot?

Yes. Leave the board on Raspberry Pi Pico W, open the motor sample, and press Simulate, then Run Blocks. Read the simulator guide if you want the windows explained.

More guides

Start Here: Open Studio