Hand Gesture Controlled RC Car with Robot Arm

The Car is used in conjuction with the glove. With the glove the car can move forward, backward, left and right. When you press the button on the glove you switch to controling the arm on the car

Engineer

Christina C

Areas of interest

Electrical Engineering

Computer Science

Mechanical Engineering

School

Los Gatos High School

Grade

Rising Junior

Final Milestone

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Second Milestone

#include <Servo.h>

Servo servo; //Create a servo “object”, called servo
//Each servo object controls one servo (you
//can have a maximum of 12).

const int flexPin1 = A0; // identfiys pins for flex sensors
const int flexPin2 = A1;
const int flexPin3 = A2;
const int flexPin4 = A3;
const int flexPin= A4;
const int buttonPin = 12; // identifits pin for button
int buttonState = 0; // says that the button starts at 0

int enA = 2; // pins for the motor controls
int in1 = 3;
int in2 = 4;
int enB = 7;
int in3 = 5;
int in4 = 6;

void setup()
{

Serial.begin(9600); //Set serial baud rate to 9600 bps

servo.attach(9); // Enable control of a servo on pin
pinMode(buttonPin, INPUT); // pin is an input
pinMode(enA, OUTPUT); // motor controls are outputs
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(enB, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);

}

void loop() {
buttonState = digitalRead(buttonPin); // the button state is the button read

if (buttonState == HIGH) { // if the button is pressed
int flexPosition1; // integer for flex sensor
int servoPosition; // integer for servo value

flexPosition1 = analogRead(flexPin1); //flex positionis the read of the flex sensor

servoPosition = map(flexPosition1, 840, 1100, 0,5 u 1
180); // the flex sensor value coresponds to servo position
servoPosition = constrain(servoPosition, 0, 180); // will only go 0-180 not further even if flex sensor is further

servo.write(servoPosition); // the servo goes to the servo position

Serial.println(“button is pressed”); // prining that the buttonis pressed

Serial.print(“sensor: “); // prining the value of the flex sensor
Serial.print(flexPosition1);
Serial.print(” servo: “); // prining the value of the servo
Serial.println(servoPosition);

}

else if (buttonState == LOW) { // if the button isn’t pressed

int flexPosition1; // flex position integers for all 5
int flexPosition2;
int flexPosition3;
int flexPosition4;
int flexBend;

flexPosition1 = analogRead(flexPin1); // the flex position is the read for that flex sensor
flexPosition2 = analogRead(flexPin2);
flexPosition3 = analogRead(flexPin3);
flexPosition4 = analogRead(flexPin4);
flexBend = analogRead(flexPin);

Serial.print(“flex1: “); // prints the value of the flex sensors
Serial.println(flexPosition1);
Serial.print(“flex2: “);
Serial.println(flexPosition2);
Serial.print(“flex3: “);
Serial.println(flexPosition3);
Serial.print(“flex4: “);
Serial.println(flexPosition4);
Serial.print(“flex: “);
Serial.println(flexBend);

if ( flexPosition1 >= flexBend){ // if the 1st flex sensor is bent more than the base then the 1st motor goes forward
analogWrite(enA, 200);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
delay(100);

Serial.println(“motor”);}

if ( flexPosition2 >= flexBend) { // if the 1st flex sensor is bent more than the base then the 1st motor goes backwards
analogWrite(enA, 200);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
delay(100);

Serial.println(“moto”);}

if ( flexPosition3 >= flexBend) { // if the 2nd flex sensor is bent more than the base then the 2nd motor goes forward
analogWrite(enB, 200);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay(100);
Serial.println(“mot”);}

if ( flexPosition4 >= flexBend) { // if the 2nd flex sensor is bent more than the base then the 2nd motor goes backwards
analogWrite(enB, 200);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(100);
Serial.println(“mo”);}

if ( flexPosition1 && flexPosition2 && flexPosition3 && flexPosition4 <= flexBend) { // if the 2nd flex sensor is bent less than the base then the 2nd motor stops
analogWrite(enA, 0);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
analogWrite(enB, 0);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
Serial.println(“NO motors”);
delay(100);}

2nd Milestone

My second milestone for my gesture controlled car is getting a button to switch between having the flex sensor control the servo and the flex sensors control the motors. The basic setup is similar to my first milestone which was one flex sensor and one servo but for this one I have added a button motor driver and 4 more flex sensors. The flex sensors are all set the same as the first one the only difference is that I used a 2kOhm resistor since there were now 5 resistors instead of 1. The basic layout of the breadboard and arduino can be seen to the left with the motor drive having each individual port plugged into the digital port and the analog ports having the flex sensors. I created this layout from Fritzing and in it you can see the specifics of the set up. The code is a series of if statements as seen to the left in the toggle window.

First Milestone

1st Milestone

The Robotic arm and wheels for my project are controlled by flex sensors, which are resistor like pieces of electronics which, when bent read a higher resistor value. This allows for things to be controlled by just bending the sensors. My first milestone was getting the flex sensor to control the servo. I started the setup of the Arduino and breadboard by connecting the 5V power and Ground source from the Arduino to the breadboard. Next, I added the flex sensor to the breadboard. The positive side of the flex sensor (which is the part with the block like circuitry)  I connected  the A0 input of the Arduino then , I added the resistor which went in the same column. Additionally, I connected the flex sensor to ground through the negative line on the flex sensor (the one with the long end). Finally, it was time to add in the servo; The orange wire was used to define the servo and plugged into port 11. I then plugged the red one to power and the brown  one for ground . The last step to get this to work was to write the code. The code for this project can be seen on the left. Through this process there were many times I had to go back and double check my work due to small things not working but the overall build in a fluid way is as described above.

#include <Servo.h>

Servo servo; //Create a servo “object”, called servo

constant int flexPin1 = A0; // set FlexSensor to pin A0

void setup()

{

Serial.begin(9600); //Set serial baud rate to 9600 bps

servo.attach(11); // Enable control of a servo on pin

}

void loop() {

int servoPosition; // create a variable for the servo position

flexPosition = analogRead(flexPin); // create a variable for the flexSensor position

// make it so the flex sensor read corresponds to the servo

servoPosition = map(flexPosition1, 860, 960, 0, 180);

 

// “clip” the values so the servo only goes from 0-180

servoPosition = constraint(servoPosition, 0, 180);

 

// have the Flex sensor position appear in the serial monitor

Serial.print(“sensor: “);

Serial.print(flexPosition1);

// have the servo position appear in the serial monitor

Serial.print(” servo: “);

Serial.println(servoPosition);

}

delay(20);}

Starter Project

Starter Project

My starter project is the useless machineI chose this project in order to learn more about solderingIt works by flipping a switch this switch cause the motor to turn forward having the acrylic piece emerge. The piece then emerges and hits the switch to the other direction causing the motor to turn the other direction and the piece to go back into the box. There is also a small switch on the inside which stops the machine from turning anymore. When the switch is flipped it also causes the LED to turn on.From this build I learned a lot about soldering and how to do it with different components. The board itself contains an LED, battery, motor, 2 switches and 2 resistors. The resistors limit the amount of current that is brought to the circuitry by the battery. I struggled with the orientation of the base to the motor module and how they fit together and getting the acrylic piece to align with the switch. It was an enjoyable process and I think it really helped me to understand the mechanics of basic electronics.

Leave a Comment

Start typing and press Enter to search