Introduction: Led Light Up Bridge With Hypersonic Sensor - Alex/Logan/Joel
Our project's purpose was to create a bridge for a hot wheels car while recreating today’s modern technology. Our project includes a hypersonic sensor to capture movement of the car. The outputs are a servo powered gate as well as LEDs that switch on when a car drives past.
Supplies
- Arduino board
- Computer
- MM wires
- Breadboard
- Hyper sonic sensor
- Screws
- Nuts
- Metal vex boards
- Hot wheels car
- Metal vex bars
- Servo motor
- Axel
- Spacers
- Alligator clips
- Battery
- Battery clip
Step 1: Build the Bridge Skeleton
- Start by acquiring a metal vex base where the bridge will be built upon
- Attach four upright supports to this base and place a platform over the top to form a bridge.
- Add a platform to the side of the bridge on one end to provide space for electronics
Step 2: Construct the Gate Hardware
- Attach the servo motor facing the same direction as the track
- Place an axel inside the server motor, again this axel should run parallel to the track
- With the axel now in place, attach a slim metal vex bar with bearing blocks to the axel which will serve as our gate
Step 3: Wire the Ultrasonic Sensor
- Attach an ultrasonic sensor to your breadboard and use wires to connect it to pins of your choice. (Trigpin, Echopin, 5v, gnd)
Step 4: Wire LEDs
- Place two LEDs in the holes of the vex material near the gate hardware. Wrap them in electrical tape so that their wires don't have contact with the metal of the bridge and only stick out the bottom.
- Attach alligator clips to the wires on the bottom of the LEDs
- Wire the LEDs to number pins of your choice using MM wires connected to the alligator clips
Step 5: Wire the Servo
- Wire the Servo to your breadboard
- Wire the breadboard connections to your Arduino with the above diagram to consolidate wires
Step 6: Attach Battery
1.Plug a battery into your Arduino board using a battery clip and remove your computer
Step 7: Code
int trigpin = 11;
int echopin = 12;
float duration_us, distance_cm;
#include
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 90; // variable to store the servo position
int G1 = 3;
int G2 =4;
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
pinMode (trigpin, OUTPUT);
pinMode (echopin, INPUT);
pinMode (G1, OUTPUT);
pinMode (G2, OUTPUT);
myservo.attach(8); // attaches the servo on pin 8 to the servo object
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);
// reads values from the ultra sonic senser every 10 microseconds
duration_us = pulseIn (echopin, HIGH);
distance_cm = 0.017 * duration_us;
// converts the value read by the ultra sonic senser into cm
delay(500);
if (0 < distance_cm && distance_cm <= 20){
for (pos = 90; pos >= 0; pos -= 1) { // goes from 0 degrees to 90 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15);// waits 15ms for the servo to reach the position
}
// Opens gate when car is near
digitalWrite(G1,HIGH);
digitalWrite(G2,HIGH);
// turns lights on
delay(5000);
for (pos = 0; pos <= 90; pos += 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
// closes gate
}
digitalWrite(G1,LOW);
digitalWrite(G2,LOW);
// turns lights off
}
}