Making a prototype hardware for a two motor rear wheel drive RC car. The 2 Motors and Servo prototype project utilizes two H-bridge controlled DC motors and a servo to create a rear wheel drive RC car. We initially built our RC car prototype on a breadboard, and then developed the idea into a moving and steering capable wireless vehicle.
Gather all of the components listed in the parts list above.
Start by placing the L293D H-Bridge on the Bread Board and connect the GND and 5V ports from the Builder Base to the GND and VCC rails on the Bread Board.
Now, we will connect the four GND pins on the H-bridge to the GND rail on the Breadboard, and the Vcc1 and Vcc2 pins on the H-Bridge to the power rail on the Breadboard.
Now, make the connections between the H-Bridge and the Builder Base as detailed in the diagram and table below:
We will now connect the Motors to the H-bridge as follows:
Lastly, we will connect the servo to the Builder Base.
On most 9G servos the GND lead is brown, the Vcc lead is orange, and the yellow lead is data, but be sure to check the data sheet of your specific servo before you proceed.
Start by taking the GND and Vcc leads from the servo and connect them to the GND and Vcc rails on the bread board. Lastly, connect the data pin to the GP2 port on the builder base. Here is a table that lists the connections:
Congrats, the hardware assembly for this project is complete!
Build the Firmware
Navigate to the Firmware Builder and create a new Firmware file. We named ours Steering Car.
Next, click the “+ Add Hardware” button and find the Motor device via the search bar, select it, name it, and then click “Add Hardware”. We named ours Motor BL.
Repeat these steps again, but this time name the motor: Motor BR.
Next, add a servo. We named ours Servo.
You should now have two motors and a servo in your devices list.
To configure the drivers for the Motor BL device, select the L293D H-Bridge driver from the driver dropdown menu.
Now, configure the driver as follows:
We will now configure the Motor BR driver:
Lastly, we will configure the Servo driver.
Select the Generic driver from the driver dropdown menu.
That’s it for the firmware! Save your file by clicking the blue “Save” Button at the bottom of the screen.
Now you can upload your firmware to the client that you have attached to the Steering Car.
Build the Application
Navigate to the Applications page and click the “+ Create New Button”, name your application, and click create.
You will now be directed to the App Builder Canvas.
Using the search bar in the left hand tool-bar search for the Motor code object and drag two of them onto the canvas.
Name the Motor Objects as we do. This will help you to identify the motors during the application mapping. To rename them click on the motor object and change the name in the properties panel on the right.
In order to save the names you must click the “Save Properties” button at the bottom of the properties tab.
Next, search for and drag a Manual Ranging object onto the canvas.
Configure the Manual Ranging object as follows:
**To configure each port on the object click on the port and change the properties in the properties panel on the right side of the screen, and hit save properties at the bottom of the screen. If you don’t your changes will not be saved!**
Next, connect the Value out port from the Manual Ranging object to the Motor objects as follows:
Now search for the “Joystick” object and drag two of them onto the canvas. Name one Left, and the other Right.
Now connect the Y-Axis port from the Joystick Left object to the Manual Ranging object as follows:
Your steering car will now move forwards and backwards with the left joystick. Next, we will work on the steering.
Search for and drag onto the canvas another Manual Ranging object and a Servo object.
We suggest that you name both of these objects.
Configure the ports on the Manual Ranging object as follows:
**We set the out min as 180 and the out Max at 0 so that when the right joystick is at rest in the centered position 90 will be output by output by the joystick instead of 0.**
With the Manual Ranging object configured we will connect the code objects as follows:
**It is possible that you will have to adjust your 0 and 180 offsets to get the proper range of motion on your servo. If this is the case, you can follow our tutorial on offset adjustment here.**
Your Steering Car is now totally usable with a set of joysticks. However, we will add some code objects that will allow the car to be controlled via the dashboard interface.
First we will start with steering. Drag three button interface objects and three static number objects onto the canvas. Arrange and name them as shown:
Now, label each of the Button objects to make them easily identifiable on the dashboard. Be sure to save the properties for each button. If you don’t, your changes will be lost!
Now make the connections highlighted in blue:
We will now move on to make the car drive forwards using the interface buttons.
Drag a Digital Toggle code object and an interface button onto the canvas. Be sure to name and label the button.
Now make the following connections that are highlighted in blue:
Congrats, your app is now complete!
Hit “Save App” and go back to your applications page.