Remote Control Car with Laser Turret
My project is a remote controlled car with a mounted laser turret. The car base is the Sunfounder car, while the mounted turret is made of 3D printed parts able to aim on 2 axes, controlled by 2 servo motors, with a laser attached as the weapon.
| Engineer | School | Area of Interest | Grade |
|---|---|---|---|
| Braden G | Berkeley High School | Civil Engineering | Incoming Senior |
Modifications
Explanation
The modifications I wanted to add to the car was originally a turret with a mounted laser that could aim 90 degrees up, and 180 degrees left and right, controlled by a the IR remote controller. These were made by CADing them in Onshape, then 3D printing the parts, and finally assembling them onto the car. Another modification I added to the car were brake lights, which would activate if the brake button was pressed. Additionally, I added turn signals, which also activate on the IR remote controller. The last modification I added was a new battery pack, containing 6, 1.5 volt batteries.
Challenges
The first challenge I faced was my micro servo motor not working. I spent a long time attempting to change the code in hopes that that was the problem, However, when I was given a secondary motor, it acted normally. The problem had turned out to be that my original motor had overheated and suffered power issues because of it. The second challenge I faced was reading signals sent from the IR remote in the Arduino code. My first problem was that I had not downloaded the correct library. My next problem was that the IR receiver code was not running properly. I eventually solved the issue with the help of an instructor by changing the code so that the IR receiver could receive the inputs.
Takeaways from BSE
One thing that I took away from BSE was that I should not be scared of coding. I had never really understood how to write code, but was able to vaguely understand it. At BSE, I was able to learn not only how to actually write code in Arduino. Another thing I learned here was how to actually apply code to electronics like through the R3 board.
Final Milestone
Explanation
My Final milestone was to download the code onto the car’s R3 board and to get it working as a self driving car. I chose this because it was the last thing in my way before the base project would have been completed.
Challenges
One challenge I faced while getting the code onto the R3 board was the code not running correctly. I solved this problem by going through each error and adjusting accordingly until the project worked. The main problem was that some movement functions were using analogue movement, while others were using digital movement.
Next Steps
The 2 main next steps for me are, in order, 1. Change the total dependence on sensor movement, with remote controlled movements. The best option for this to my knowledge is the IR sensor and remote. 2. 3D print parts for attach a two axis laser pointer turret to the car, hopefully controlled remotely by a joystick, as well as adjust the wiring and circuitry organization on the car.
Second Milestone
Explanation
My second milestone was to wire all of the modules together, so that when code is downloaded and run on the machine, nothing breaks or stops working.
Challenges
One Challenge I faced during this milestone was figuring out how the wiring system works on the car and deciding whether the videos or schematics were better to follow. I solved this problem by following the schematics, as they were clearer to follow than the videos.
Next Steps
The next thing that needs to be done is to write and download the code onto the R3 board of the car and to make sure that all sensors work properly with the code.
First Milestone
Explanation
My First Milestone was to acquire all parts for the car, which includes the 2 TT wheels, 1 Universal Wheel, 2 TT motors, the R3 board, L9110 Module, Ultrasonic Module, 2 IR obstacle Avoidance Modules, mini bread board, nuts and bolts to secure them, and wires to connect parts together. Along with Gathering all parts, I also needed to assemble them onto the base plate, so that the car can actually drive.
Challenges
One challenge that I faced when gathering and assembling the car was not having correctly sized screws to attach some modules. I solved this problem by asking around and finding replacement screws from the spare parts cabinet.
Next Steps
My plan after this is to wire all the parts together (Milestone 2), and download the self driving car code onto the R3 Board (final Milestone).
Starter Project
Explanation
My starter project was the adjustable LED light. It consists of a circuit board, 3 sliders, each controlling the intensity of either red, green, or blue light on the LED, a USB-C adapter, and a multi-colored LED. The main goal of the project is to solder all of the parts to the circuit board in order to make the light color adjustable when powered.
Challenges
the main challenge for me was remembering how to solder parts. Fortunately, before I began this project, I was allowed to practice on a spare circuit board. Still, the first slider’s soldering is rather mediocre. However, by the time I got to the third slider’s soldering, the quality had improved drastically.
Schematics
3D Prints
Code
Here is the code that my car runs on
#include <Servo.h> // servo motor library
#include <IRremote.hpp> // IR remote library
//setting pins to different outputs, ie, IRreviever, wheel motors, servo motors.
const int IR_RECEIVE_PIN = 12;
const int A_1B = 5;
const int A_1A = 6;
const int B_1B = 9;
const int B_1A = 10;
const int servoPinY = 3;
const int servoPinX = 2;
//creating X and Y axis servo objects
Servo servoY;
Servo servoX;
//setting integer starting values
int x = 0;
int y = 90;
void setup() {
Serial.begin(9600);//communication channel for arduino uno board
//attaching servos and sending them to starting positions
servoY.attach(3);
servoY.write(0);
servoX.attach(2);
servoX.write(90);
//allow IR reviever to being recieving
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver
Serial.println("REMOTE CONTROL START");
//attach wheel motors
pinMode(A_1B, OUTPUT);
pinMode(A_1A, OUTPUT);
pinMode(B_1B, OUTPUT);
pinMode(B_1A, OUTPUT);
delay(1000);
}
//function for moving forward using TT motors
void moveForward() {
digitalWrite(A_1B, LOW);
digitalWrite(A_1A, HIGH);
digitalWrite(B_1B, HIGH);
digitalWrite(B_1A, LOW);
}
//function for moving backwards using TT motors
void moveBackward() {
digitalWrite(A_1B, HIGH);
digitalWrite(A_1A, LOW);
digitalWrite(B_1B, LOW);
digitalWrite(B_1A, HIGH);
}
//same as above but right
void turnRight() {
digitalWrite(A_1B, HIGH);
digitalWrite(A_1A, LOW);
digitalWrite(B_1B, HIGH);
digitalWrite(B_1A, LOW);
}
//and left
void turnLeft() {
digitalWrite(A_1B, LOW);
digitalWrite(A_1A, HIGH);
digitalWrite(B_1B, LOW);
digitalWrite(B_1A, HIGH);
}
//function to stop all movement
void fullstop() {
digitalWrite(A_1B, LOW);
digitalWrite(A_1A, LOW);
digitalWrite(B_1B, LOW);
digitalWrite(B_1A, LOW);
}
//continuous loop for whole project
void loop() {
//if the reciever recieves a button input from the IR remote, it prints the button ID
if (IrReceiver.decode()) {
uint32_t key = IrReceiver.decodedIRData.command;
Serial.println(key, HEX);
//if key 2 is pressed(ID of 18), move forward
if (key == 0x18) {//0x is before the ID because some ID's include letters, and 0x allows reading of letters and numbers
moveForward();//calls function
Serial.println("HELLO");//says hello in console, to confirm action
delay(10);
}
//if key 4 is pressed(ID of 8), turn left
if (key == 0x8) {
turnLeft();
Serial.println("HELLO");
delay(10);
}
//if key 6 is pressed(ID of 5a), turn right
if (key == 0x5a) {
turnRight();
Serial.println("HELLO");
delay(10);
}
//if key 8 is pressed(ID of 52), move backwards
if (key == 0x52) {
moveBackward();
Serial.println("HELLO");
delay(10);
}
//if key 5 is pressed(ID of 1c), stop
if (key == 0x1c) {
fullstop();
Serial.println("HELLO");
delay(10);
}
//if key - is pressed(ID of 15), aim laser upwards
if (key == 0x15) {
y=y+2;//add 2 to the Y integer
servoY.write(y); //write the new Y angle to the servo
Serial.print(" : ");
Serial.print(y); //display new Y value in console
Serial.print(" : ");
}
//same as above, but for key below -, and aims laser down
if (key == 0x19) {
y=y-2;
servoY.write(y);
Serial.print(" : ");
Serial.print(y);
Serial.print(" : ");
}
//same as above, but controls positive X axis on u/sd button
if (key == 0x16) {
x=x+2;
servoX.write(x);
Serial.print(" : ");
Serial.print(x);
Serial.print(" : ");
}
//same as above, but controls negative x axis on 0 button
if (key == 0xd) {
x=x-2;
servoX.write(x);
Serial.print(" : ");
Serial.print(x);
Serial.print(" : ");
}
IrReceiver.resume(); // Enable receiving of the next value // Waits 1 second
}
}