Build and program the Funduino 3D RoboCar

FunduinoLast updated on

Vom 3D-gedruckten Gehäuse bis zum Hindernisparcours mit OpenRoberta

An einem fahrenden Roboter lässt sich unmittelbar ablesen, was ein Programm bewirkt – deshalb gehören kleine Roboterfahrzeuge zu den beliebtesten Arduino-Projekten im Unterricht. Das 3D-RoboCar ist genau dafür gebaut: ein gedrucktes Gehäuse, zwei Motoren, ein Ultraschallsensor und ein Mikrocontroller, den Schülerinnen und Schüler selbst verkabeln.

Diese Anleitung führt vom Zusammenbau über die Elektronik bis zur Programmierung. Programmiert wird visuell auf Blockbasis mit OpenRoberta – in sieben aufeinander aufbauenden Aufgaben, von der ersten Geradeausfahrt bis zum Roboter, der Hindernissen ausweicht.

3D-printed robot vehicle with two wheels and an ultrasonic sensor
The fully assembled 3D RoboCar
Comparison of the UNO and NANO versions of the 3D RoboCar
Both versions: the Arduino UNO on the left, the Arduino NANO on an UNO-format shield on the right.
Exploded view of the 3D RoboCar with numbered components
The assembly sequence
1 / 3

What makes the 3D RoboCar special

Small, speedy robots have been among the most popular Arduino projects in the classroom for years. They clearly show the effect of a line of code: the connection between a command and a movement becomes visible. With a few additional modules, they become automated robots - an ultrasonic sensor lets them detect and avoid obstacles, while line-tracking sensors let them follow a line.

There are many chassis for robots like these. The components of the 3D-RoboCar have been deliberately chosen so that the robot can be programmed using either the original Arduino software or a visual block-based programming language, such as OpenRoberta. All parts are inexpensive to replace or reprint, making the robot a sustainable choice for classroom use, even if something breaks.

The 3D-RoboCar is designed for an Arduino UNO or an Arduino NANO with a compatible UNO-format shield. This guide always shows the UNO, but the same instructions apply to both.

3D-printed robot vehicle with two wheels and an ultrasonic sensor
The fully assembled 3D RoboCar
Comparison of the UNO and NANO versions of the 3D RoboCar
Both versions: the Arduino UNO on the left, the Arduino NANO on an UNO-format shield on the right.
1 / 2

For the classroom: Requirements and differentiation

What students should bring or learn during the project:

  • Solder wires to the motors (four solder joints)
  • Read simple circuit diagrams
  • Wire a microcontroller, two motors, a battery, and a motor driver
  • Fasten wires in screw terminals with a screwdriver
  • Program with the Arduino software or OpenRoberta
  • Print the enclosure with a 3D printer - with support from the teacher if needed

For faster groups, consider:

  • Design their own 3D parts - designs, antennas, spoilers, snowplows, for example with Tinkercad
  • Add line following to the electronics
  • Add Bluetooth to the electronics

Enclosure design at a glance

The housing is compactly designed: Every electrical component has its designated place. It consists of just two printed parts - the main body and a hemisphere that serves as a slider.

The slider is more important than it looks: It ensures that the vehicle sits level on the ground. Without it, the ultrasonic sensor would point diagonally upward and fail to detect obstacles.

Assemble the parts in the following steps.

Exploded view of the 3D RoboCar with numbered components
The assembly sequence

Mount motors and wheels

The motors are pressed into their slots one after the other. The motor shaft is fed out through the small hole; with a little pressure, the motor slides all the way out into its cutout.

Then gently press the two wheels onto the axles.

Solder the wires to the motors before installing them. Soldering is very difficult once they’re installed. However, the motors are only plugged in, not glued, so you can remove them again at any time.

Housing with installed motors and attached wheels
Insert the motors and slide the wheels onto the axles.

Insert speaker

The small speaker goes into the round recess between the two motors. Make sure the two contacts face upward so you can reach them later.

Enclosure with installed speaker
Place the speaker in the round recess between the motors with the contacts facing up.

Use the motor driver

The motor driver is placed in the rear section of the enclosure. It does not need to be secured or glued in place, so you can stay flexible while tinkering and still access the screw terminals later.

Enclosure with L298N motor driver installed
The motor driver is placed loose in the rear compartment.

Use sensors

Finally, mount the ultrasonic sensor at the front and the two line-tracking sensors facing downward in their holders.

The line-tracking sensors are already installed here, but are not used in this guide yet. They are intended for adding line-following functionality. If you don't need them at first, you can leave them out and add them later.

Housing with an installed ultrasonic sensor and two line-tracking sensors
Finally, the ultrasonic sensor and the two line-tracking sensors are put in place.

Connect the wiring

All sensors and actuators are now exposed - only the microcontroller is still missing. This is the best time to wire up the inside, because you can easily reach everything. Wire all the modules according to the circuit diagram, but don't connect the microcontroller yet.

Feed the four wires from the motor driver (IN1, IN2, IN3, IN4) and the two power supply wires (GND and 5V) out through the side holes in the enclosure. Leave them hanging there until the microcontroller is installed.

Circuit diagram with microcontroller, motor driver, motors, speaker, and sensors
The wiring diagram for the inside

Insert the battery

The 9 V battery is placed on top of the motor driver and connected to its screw terminals. Depending on the battery clip, you may first need to cut off an existing plug - the bare wire ends go directly into the screw terminals.

Two wires end up at the GND terminal: the battery's negative terminal and the GND wire to the microcontroller.

Practical tip: Rechargeable 9 V batteries are available that can be charged via USB cable. They’re better for the environment and your wallet - especially when several groups are working at the same time.

3D RoboCar with 9-volt battery inserted
The 9 V battery is on top of the motor driver.

Assemble microcontrollers

Slide an Arduino UNO into the designated slot from the rear, all the way to the top. It will then cover most of the electronics inside.

Instead, snap an Arduino NANO into its holder on the back. Its pin headers fit into the slot between the robot base and the glider.

Connect the cables as you slide it in, as soon as their length allows - it gets tight afterward.

3D robot car with mounted Arduino UNO
The microcontroller is inserted into the top slot from the back.

Place the mini breadboard

In the final assembly step, place a mini breadboard on top of the microcontroller. As with larger breadboards, the long rows are electrically connected.

This gives you multiple 5V and GND connections, which you need as soon as several sensors are connected at the same time.

Why a motor driver is needed

The 3D RoboCar runs on two DC motors. They need significantly more current than a microcontroller’s digital output can supply - it can provide only a few tens of milliamps, which would at most make the robot shake.

That’s why the motors get their power from a motor driver, not the microcontroller. The microcontroller only sends control signals; the driver switches the actual power. The 3D RoboCar uses the widely used L298N for this. Depending on their design, these components are also called an H-bridge or motor shield.

The ready-made board has screw terminals, connectors, and a heat sink. You can connect two motors to it and control them independently.

Circuit diagram of the 3D RoboCar with all modules
The entire electronics setup at a glance

The connections of the L298N

The L298N has more connections than you need at first. The diagram numbers them:

  • 1 and 2 – connections for DC motor 1 (positive and negative)
  • 3 – the 5V jumper: when connected, it switches on the built-in 5-volt regulator
  • 4 – power supply input for the H-bridge
  • 5 – GND input
  • 6 – 5V output, for example to power the microcontroller
  • 7 – enable pin for motor 1 (ENA): enables the motor and controls its speed via PWM
  • 8 and 9 – IN1 and IN2, the control inputs for motor 1
  • 10 and 11 – IN3 and IN4, the control inputs for motor 2
  • 12 – enable pin for motor 2 (ENB)
  • 13 and 14 – connections for DC motor 2 (positive and negative)

At first, you only need the motor connections, the power supply, and IN1 through IN4. The enable pins only come into play when you want to control the speed.

Leave the 5V jumper installed for this project - only then will the module generate the 5 volts needed to power the microcontroller. You only need to remove it if you operate the driver above 12 volts; then you’ll need a separate power supply for the microcontroller.

Sketch of the L298N module with numbered connections
The connections of the L298N motor driver, numbered

Power supply for the entire system

The vehicle has just one power source: the 9 V battery. Connect it to the motor driver terminals labeled 12V and GND.

The 12V label is a little misleading. It doesn’t mean that exactly 12 volts must be supplied there; it marks the maximum voltage at which you can use the built-in voltage regulator. This regulator also converts the battery voltage to 5 volts - and that’s what powers the microcontroller. So you don’t need a second power source.

Connect the microcontroller to the motor driver’s 5V output and GND. Then connect four wires from the microcontroller’s digital pins 2, 3, 4, and 5 to IN1, IN2, IN3, and IN4 - these four pins control all the movements.

Connect the two motors to the two-pole screw terminals on opposite sides. You don't need to pay attention to the polarity: if a wheel later turns the wrong way, simply swap the two wires for that motor.

How IN1 to IN4 control the motors

IN1 and IN2 determine what Motor 1 does; IN3 and IN4 do the same for Motor 2. The microcontroller sets each of these lines to HIGH or LOW – HIGH means 5 volts are present at the pin, LOW means there is no voltage.

The combination of the two determines the direction of rotation:

  • LOW / LOW – the motor is stopped
  • LOW / HIGH – the motor rotates forward
  • HIGH / LOW – the motor rotates backward
  • HIGH / HIGH – the motor is stopped

The same applies to Motor 2 using IN3 and IN4. With these four signals, you can make both motors turn in the same or opposite directions – and that’s exactly how the robot moves straight ahead, backward, or spins around its own axis.

Set up OpenRoberta

You can program the robot using the Arduino software in the traditional way or visually with blocks. Here we use the cloud-based platform OpenRoberta at lab.open-roberta.org.

To transfer programs created in the browser to the microcontroller via USB, you also need the small Open Roberta Connector utility. It requires an installed Java runtime environment, which you can get if needed from java.com bekommst. Den Connector selbst lädst du in der jeweils aktuellen Version von GitHub Download the Connector itself in the latest version from

If an error message appears when the connector starts, Java is either not installed or installed incorrectly. Install it, then restart the connector.

GitHub page with the Open Roberta Connector downloads
The Open Roberta Connector releases on GitHub
Open Roberta Connector window
This is what the Open Roberta Connector looks like after installation.
Error message when starting the Open Roberta Connector
This message appears when Java is missing or incorrectly installed.
1 / 3

Connect the microcontroller to the lab

Connect the microcontroller to your computer via USB. The Connector detects it and selects it automatically. Click “Connect” to establish a connection to lab.open-roberta.org; the application confirms it by generating a combination of numbers and letters – the token.

Now open lab.open-roberta.org in your browser and select the system Nepo4Arduino – this is the correct entry for Arduino microcontrollers. Click “Robot,” then “Connect,” and enter the token.

There are three important items in the menu bar:

  • Edit – create, load, export, and import programs. Export saves a program to your PC, while import loads it back into the Lab.
  • Robot – connect the microcontroller here using the token.
  • Users and Groups – an account isn’t required, but it lets you save your own programs online. Group login is intended for working with school classes.
Open Roberta connector with recognized Arduino
The connected microcontroller is detected automatically.
Open Roberta connector with displayed token
After connecting, the application generates a token consisting of numbers and letters.
Selection of robot systems in the Open Roberta Lab
The overview of systems in the Open Roberta Lab - for Arduino, Nepo4Arduino is the right one.
Open Roberta Lab with menu bar and blank programming area
The web interface of the Open Roberta Lab with its three important menu items
Robot dropdown menu in the Open Roberta Lab
The microcontroller is connected to the website via Robots → Connect
Input field for the connection token in the Open Roberta Lab
The token from the connector is entered here.
1 / 6

The robot configuration

In the configuration, you tell the software which module is connected to which port. To start with, the two motors, the speaker, and the ultrasonic sensor are enough.

Ultrasonic sensor example: The green HC-SR04 block gets a name – here, S1 – and two ports. “trig” is the sensor’s trigger pin, connected to digital port 9 in the example; “echo” is the echo pin, connected to digital port 8.

For the motors, use the orange “Digital actuator” block four times. It can output a 5-volt signal (HIGH) or GND (LOW) via a digital pin – exactly what the motor driver expects at IN1 to IN4. In the example, these four blocks are named Motor1a (IN1), Motor1b (IN2), Motor2a (IN3), and Motor2b (IN4).

Attention: The ports in these screenshots do not match the wiring diagram from the wiring step. Your own setup is what matters - enter exactly the ports where your cables are actually plugged in. Go through each module once: Which cable comes from which module, and where does it end up on the microcontroller?

Robot configuration in the Open Roberta Lab with an ultrasonic sensor and four actuator blocks
The robot configuration: this is where you enter which module is connected to which port.

Task 1: drive straight ahead

Both wheels should turn forward. To do this, all four inputs on the motor driver need to receive a signal.

Every program starts with the red forever loop block. Inside it, add the “Write value” block four times. You’ll find it in the menu on the left under “Action” and “pin”. Enter either a 1 or a 0 in the blue field: 1 means 5 volts at the pin, and 0 means GND—that is, HIGH and LOW.

If one or both wheels then turn backward, simply swap the 1 and 0 for that motor. As soon as the battery is connected, the robot will start moving.

Empty loop block in Open Roberta Lab
The starting point of every program: the red infinite loop
Menu area Action with the Write Value block
You can find the “Write Value” block in the menu under “Action” and “pin”
Open Roberta program with four write-value blocks
Solution to exercise 1: four components switch the four inputs of the motor driver
1 / 3

Tasks 2 and 3: drive backward and turn

To reverse, you only need to swap the values from Task 1 - change every 1 to a 0 and vice versa.

To make the robot rotate around its own axis, one wheel must turn forward and the other backward. So you only need to change the values for one of the two motors.

Alternatively, keep one wheel completely still and turn only the other. The robot will then rotate around the stationary wheel rather than turning on the spot.

Open Roberta program for reversing
Solution to exercise 2: the values are swapped compared to exercise 1
Open Roberta program for rotating around its own axis
Solution to exercise 3: one wheel forward, the other backward
Open Roberta program for rotation with only one motor
Alternative to task 3: one wheel is stationary, only the other one turns
1 / 3

Task 4: play a melody

Now the robot should make a sound. The drive remains unused in this task; you only need the sound-generation block from the “Action” and “Sound” menus.

With a single block, the robot plays a 300-hertz tone for 1000 milliseconds. Because the loop keeps calling it, this creates a continuous tone - anything but a cheerful melody.

Only several blocks with different pitches and durations create a melody. Give it a try - with a little feel for sequences of notes, the robot will soon sound really friendly.

Open Roberta program with a sound block
A single tone: 300 hertz for 1000 milliseconds
Open Roberta program with multiple sound blocks
Solution to Exercise 4: several notes in a row make a melody
1 / 2

Task 5: respond to an obstacle

Now the melody should only play when the ultrasonic sensor detects an obstacle. The “get distance” block in the “Sensors” menu provides the measurement.

When you drag it into the program, you’ll notice that it can’t snap into place anywhere and stays faded out. That’s because a sensor value is always used within a control function. So first you need an If block.

You then connect a logic condition to this If block - the question is: What should happen when a particular condition is met? In our example, the melody should play as soon as the measured distance is less than 40 centimeters.

Sensor menu area with the block “give distance”
The block “report distance” from the “Sensors” menu
Open Roberta program with an if block
The sensor value can only be used in conjunction with a control function.
Open Roberta program with if block and comparison operator
A logic is linked to the control function.
Open Roberta program with distance checks and sound blocks
Solution to exercise 5: a melody as soon as the distance falls below 40 centimeters
1 / 4

Tasks 6 and 7: stop and avoid obstacles

For task 6, the robot should not only play a melody when it encounters an obstacle, but also stop. You don't need any new blocks for this - just combine what you already know: the distance check from task 5 and stopping from task 1.

Task 7 takes it a step further: after stopping, the robot should turn and continue moving in a different direction. You can build this using only the blocks you already know.

At the latest, the program becomes confusing here: every single movement takes four blocks. The next step solves exactly that.

Open Roberta program that stops the motors and plays a tone
Solution to Exercise 6: stop and play a melody
Long Open Roberta program with many individual blocks
Solution to exercise 7 without functions - the program quickly becomes hard to follow
1 / 2

Clean up with functions

A function groups several blocks under one name. Instead of placing four blocks each time, you call the function in the main program with just one block.

To do this, create five functions: Forward, Backward, Stop, Turn, and Melody. They will then appear in the “Functions” menu and can be used as often as you like.

Task 7 looks much tidier right away – and if you later change the direction of rotation, you only need to change it in one place instead of five.

Open Roberta program with five defined functions
Five custom functions: forward, backward, stop, turn, and melody
Menu section with the custom-created blocks
The custom functions will then appear in the “Functions” menu.
Compact Open Roberta program with function calls
The same task with functions - much shorter and easier to read
1 / 3
Rate the instructions

Comments

Ask a question or share an experience

Contact us if something doesn’t work. Please include your board and the error message.

We review every comment before publication. Your email address remains with us.