Led Light Up Bridge With Hypersonic Sensor - Alex/Logan/Joel

by PHS_Engineering in Circuits > Arduino

40 Views, 0 Favorites, 0 Comments

Led Light Up Bridge With Hypersonic Sensor - Alex/Logan/Joel

Alex_Logan_Arduino_video

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

Build the Bridge Skeleton

image.jpg
image.jpg
  1. Start by acquiring a metal vex base where the bridge will be built upon
  2. Attach four upright supports to this base and place a platform over the top to form a bridge.
  3. Add a platform to the side of the bridge on one end to provide space for electronics


Construct the Gate Hardware

image.jpg
  1. Attach the servo motor facing the same direction as the track
  2. Place an axel inside the server motor, again this axel should run parallel to the track
  3. With the axel now in place, attach a slim metal vex bar with bearing blocks to the axel which will serve as our gate

Wire the Ultrasonic Sensor

image.jpg
image.jpg
  1. Attach an ultrasonic sensor to your breadboard and use wires to connect it to pins of your choice. (Trigpin, Echopin, 5v, gnd)

Wire LEDs

image.jpg
image.jpg
images.png
  1. 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.
  2. Attach alligator clips to the wires on the bottom of the LEDs
  3. Wire the LEDs to number pins of your choice using MM wires connected to the alligator clips

Wire the Servo

unnamed.jpg
download.png
  1. Wire the Servo to your breadboard
  2. Wire the breadboard connections to your Arduino with the above diagram to consolidate wires

Attach Battery

1.jpg

1.Plug a battery into your Arduino board using a battery clip and remove your computer

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

}


}

Final Product

Alex_Logan_Arduino_video