This project is designed to teach someone to build a simple Arduino enabled car, with commonly accessible parts. I wanted to bring together the learnings from my experience build a car without a readymade kit. It works with easy to find parts and requires no paid android applications to run.
It works by connecting the android app to the hc-05 and voila! The car will go left, right, forward and backwards !
Arduino WiringHC05
1. Connect the VCC of the HC05 to 5v of the Arduino
2. Connect the GND of HCO5 to the GND of the Arduino
3. Connect TXD to RX on the Arduino
4. Connect RXD to TX on the Arduino
L298N
1. Powering the L298N. Use a 7.4v LiPo battery. Connect the red battery wire to the 12v pin on the L298N via a male to male jumper wire. Connect a black male to male wire to GND.
2. Connecting the left motor pins to Arduino:
- ENA -> Pin3
- IN1 -> Pin4
- IN2 -> Pin5
3. Connecting the right motor pins to Arduino:
- IN3 -> Pin13
- IN4 -> Pin12
- ENB -> Pin11
4. Wiring the Motors into L298n: Put both red wires from the same into the same output pins. Do the same for black.
Powering the Arduino
Updated 2/4/2023
The Arduino is powered via VIN which will need a male to male jumper wire connecting VIN to 5v on L298N and GND TO GND.
Arduino IDE
To understand the concepts, there are 3 pieces that talk to each other.
Each side of the car has 2 dc motors. Both motors connect to the same 3 pins that regulate turning the motor on and off and direction.
EN pins turn motors on and off.
IN pins determine direction of motors (forward and backwards).
Output pins power the motors. They draw current from the L298N and need a 7.4v battery to work.
The Arduino code is below.
The arduino code can be understood as the receiver for the android applications commands.
The android app sends a letter to the HC05 which then talks to the arduino.
The Arduino code reads that letter then activates the pins to run the motor. If you push forward, the app sends an F to the HC05. The F is then translated by the arduino code to run the motorpins for both sides of the car.
Look at the motor pins in the Arduino code, then check the MotorPin variables to understand which letters trigger which MotorPins
Android ApplicationYou can download this via the MIT AI Companion. Check the Blocks tab to understand the logic of the application and how it talks to the arduino, which then triggers the motors.
Very broadly, the flow is
- > Forward button in Android App
- > Sends an F to HC05
- > Arduino Pins connected to both the and right motors run
https://gallery.appinventor.mit.edu/?galleryid=f7bd19d3-5d4e-477e-9c68-66a8afd68244
Conclusion and Thoughts
This project was born out of my desire to build a Bluetooth car and finding different tutorials solved different parts of the problem, but not the entire problem. I decided to create this once I had solved the problem for myself for an end to end Bluetooth controlled l298n Arduino with all open source components and code. I am not an expert and this was self taught. If you have feedback or ways to improve the project, please contact me. Its a work in progress and we learn by working together.
Comments