Remote Controlled Car

My project is a button controlled robot car. The robot responds to signals from three buttons, prompting it to move depending on the button.

Engineer

Noe ZR

Area of Interest

Biomedical Engineering

School

Marble Hill School for International Studies

Grade

Incoming Senior

Final Milestone

For my second milestone, I managed to establish basic XBee to XBee communication.

This portion of my project was important in order to establish a connection between my flex sensor glove and claw/wheels of the car.

Like my previous milestone, I was unaware of what to do. I struggled to find an application to establish a connection. After a couple of hours of looking for instructions, and downloading incorrect applications, I eventually found a website that told me what to do.

I then downloaded the XTCU application and followed the directions given to me.

Despite this, I struggled to connect more than one XBee because I tried to connect both XBee to a single XBee explorer. I kept receiving serial port errors, and after a while, I realized that my problem was not having a second XBee explorer.
After getting a second explorer my problem was not having USB ports on my computer, but that was solved with a simple USB adapter.

When I solved all these issues I was able to establish wireless connections between both XBee.

First Milestone

For my first milestone, I got the flex sensors to display readings, depending on how much they were bent. This was important for my project because I have to use a flex sensor glove to control my car. At first, I had no clue what I was doing. But I found a schematic online, that showed how I would set up the different parts and the code necessary to have it function. I then connected the Arduino Uno to my laptop and used the code that was provided on the website I found. From then I followed the schematic of how I would connect the jumper wires to the breadboard and Arduino Uno. After that, I was able to get readings for a single flex sensor. After that, I had to get readings for all four of my flex sensors simultaneously. For this part, I actually had to do it, for the most part, on my own. Essentially what I had to change from the prior process was the jumper wire connections and code. I recreated the way the wires were connected for each of the four flex sensors, based on the initial flex sensor. After I recreated the setup for all the flex sensors I had to change a couple of wires to match the ground and 5V connections. My main difficulty with the problem was understanding the positive and negative ends on the breadboard. Mostly because I wasn’t getting readings from my flex sensors. Another difficulty I had was making the code to get four readings at the same time. All I had to do, however, was copy and paste the single flex sensor code and change the plugin ports on the Arduino Uno.

Starter Project

For my starter project, I built the BigTime Watch; it is essentially a digital watch. I chose this project for the simplicity of the structure and its common usage. The main parts of the project were the PCB board and the ATmega328 that came with the project. I didn’t have to do much work with the ATmega328, because it arrived preprogrammed. The PCB board holds the entire project physically and electrically. By soldering, the ATmega328’s wires are able to flow through the circuit board, when electricity is introduced. The capacitor and resistors are also soldered onto the circuit board for the necessary flow of electricity. The resistors also help to stabilize the usage of electricity and ends the circulation of electricity once a certain amount of time has passed, which helps with how the microcontroller came preprogrammed. I had a few setbacks, all relating to soldering. It is important to not solder wires, or parts in general, incorrectly or too close to one another. I had to desolder the battery holder because its position would not allow for the battery to be placed, and as a result, the watch could not be powered.

String inputString = “”; // a String to hold incoming data
boolean stringComplete = false; // whether the string is complete
int ena=3;
int n1=4;
int n2=5;
int n3=6;
int n4=7;
int enb=11;
void setup() {
// initialize serial:
Serial.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
pinMode(ena, OUTPUT);
pinMode(enb, OUTPUT);
pinMode(n1, OUTPUT);
pinMode(n2, OUTPUT);
pinMode(n3, OUTPUT);
pinMode(n4, OUTPUT);
}

void loop() {
analogWrite(ena, 255);
analogWrite(enb, 255);

// print the string when a newline arrives:
if (stringComplete) {

if(inputString==”f”){
forward();
}
if(inputString==”l”){
left();
}
if(inputString==”r”){
right();
}
if(inputString==”s”){
stop_now();
}
Serial.println(inputString);
inputString = “”;
stringComplete = false;
}
}

void forward(){
digitalWrite(n1, HIGH);
digitalWrite(n2, LOW);
digitalWrite(n3, HIGH);
digitalWrite(n4, LOW);

}

void left(){
digitalWrite(n1, HIGH);
digitalWrite(n2, LOW);
digitalWrite(n3, LOW);
digitalWrite(n4, HIGH);

}

void right(){
digitalWrite(n1, LOW);
digitalWrite(n2, HIGH);
digitalWrite(n3, HIGH);
digitalWrite(n4, LOW);

}

void stop_now(){
digitalWrite(n1, LOW);
digitalWrite(n2, LOW);
digitalWrite(n3, LOW);
digitalWrite(n4, LOW);

}
/*
SerialEvent occurs whenever a new data comes in the hardware serial RX. This
routine is run between each time loop() runs, so using delay inside loop can
delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:

}
stringComplete = true;

}

int ena=3;
int n1=4;
int n2=5;
int n3=6;
int n4=7;
int enb=11;
void setup()
{
pinMode(ena, OUTPUT);
pinMode(enb, OUTPUT);
pinMode(n1, OUTPUT);
pinMode(n2, OUTPUT);
pinMode(n3, OUTPUT);
pinMode(n4, OUTPUT);
}

void loop()
{
digitalWrite(n1, HIGH);
digitalWrite(n2, LOW);
analogWrite(ena, 80);
digitalWrite(n3, HIGH);
digitalWrite(n4, LOW);
analogWrite(enb, 80);
delay(1000);
digitalWrite(n1, LOW);
digitalWrite(n2, HIGH);
analogWrite(ena, 80);
digitalWrite(n3, LOW);
digitalWrite(n4, HIGH);
analogWrite(enb, 80);
delay(1000);
}

void setup() {
Serial.begin(9600);
pinMode(A1,INPUT);
pinMode(A2,INPUT);
pinMode(A3,INPUT);

}

void loop() {
if(digitalRead(A1)){
Serial.println(“l”);
}
else if(digitalRead(A2)){
Serial.println(“f”);
}
else if(digitalRead(A3)){
Serial.println(“r”);
}
else {
Serial.println(“s”);
}
delay(10);
}

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering