Vex Robot by George Theall, George Ayer, Finn Snow
by PHS_Engineering in Circuits > Arduino
470 Views, 1 Favorites, 0 Comments
Vex Robot by George Theall, George Ayer, Finn Snow
Our robot combines a VEX kit engine and frame with an Aurduino brain controlling these components. The robot will receive inputs from a ultrasonic sensor that tells it when to turn to avoid hitting obstacles. The use of omni-wheels makes the “Roomba” more mobile and allows it to turn and drive in any direction at any moment.
Downloads
Supplies
Vex V5 Kit Items
4x Omnidirectional wheels
4x vex motors
Bolts and nuts
Drive shafts
Screws
Battery pack(10 volts)
Jumper wires
4x Transistors
Prototype Expansion Module
Arduino Uno
Ultrasonic sensor
Build the Frame
To start, gather your V5 Vex kit parts and create an open flat frame of your choice make sure that it has space for a motor facing each direction.
Wiring
For the wiring of the car, you will want to follow this diagram. Use the prototype expansion module to get 5 extra 5 volt and ground ports each. Another very important step is to ensure that the transistors are facing the correct direction. Using the diagram, the side that is facing up should be the flat side. If possible, place the ultrasonic sensor on a different, preferably smaller breadboard so it has more freedom of placement. Connect the vex motors to the bread board.
Coding
int TRIG_PIN = 7; // Arduino pin connected to Ultrasonic Sensor's TRIG pin int ECHO_PIN = 6; // Arduino pin connected to Ultrasonic Sensor's ECHO pin int RW = 13; // Right wheel int LW = 12; // Left wheel int FW = 11; // Front wheel int BW = 10; // Int for back wheel int DT = 50; // Distance Threshold in centimeters // variables will change: float duration_us, distance_cm; void setup() { Serial.begin (9600); // initialize serial port pinMode(TRIG_PIN, OUTPUT); // set arduino pin to output mode pinMode(ECHO_PIN, INPUT); // set arduino pin to input mode pinMode(RW, OUTPUT); // set arduino pin to output mode pinMode(LW, OUTPUT); // set arduino pin to output mode pinMode(FW, OUTPUT); // set arduino pin to output mode pinMode(BW, OUTPUT); // set arduino pin to output mode } void loop() { // generate 10-microsecond pulse to TRIG pin digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); // measure duration of pulse from ECHO pin duration_us = pulseIn(ECHO_PIN, HIGH); // calculate the distance distance_cm = 0.017 * duration_us; if(distance_cm <= DT) { // Turn on the front and back wheels to turn the car digitalWrite(BW, HIGH); digitalWrite(FW, HIGH); analogWrite(RW, 255); digitalWrite(LW, LOW); delay(600); } else { // Turn on the side wheels to make the car go forward analogWrite(LW, 200); analogWrite(RW, 255); digitalWrite(FW, LOW); digitalWrite(BW, LOW); } // print the value to Serial Monitor Serial.print("distance: "); Serial.print(distance_cm); Serial.println(" cm"); delay(500); }
The code for the car is pretty simple, with no libraries required. The int’s pair all the motors and sensors to a pin, and set a distance threshold for the ultrasonic sensor. The void setup ()establishes whether each pin is an input or output. The main section of code, the void loop ()sends the ultrasonic sensor into action, and if the sensor reads less than the distance threshold, it will turn the car. else the car will continue to move forward.
Observe the Final Product
This Robot allows for some customizability and reprogramming. Parts of some VEX models are interchangeable, allowing you to mix and match features, or switch to other units for longer battery life. Additionally, some of them can be adapted to perform more creative tasks using a library in conjunction with the Aurduino.