top of page

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

At the bottom of this page is my test video of the H bridge(with L293d chip to build the circuit). I add a potentiometer to control the speed of the motor and I use the press button to control the direction of the motor.

 

It is very easy to build the H-bridge with the L293d chip and it is capable of controling two motors(each side of the pins control one motor).

 

To better undrestand how this chip works, let's take the left side of the chip as an example. (From top to bottom)the first chip is the enable pin, only when the digital signal is high, the chip works. The second chip is the direction control (A1)of the motor. When the signal is HIGH, the motor will rotate in one direction. And the third one is the motor positive connected that should be directly connected to the positive side of the motor. The fourth and the fifth pins are both ground which should be connected to the GND. And the sixth is the negative side of the motor, the seventh is another direction control of the motor(A2). When the state on pin7 is HIGH, the motor will rotate in the other direction. The last pin is the power pin for the motor which gives the motor enough power(it should be connected to power source(up tp 36V)   

 

 

 

 

Next week, Shihan and I will build an automatic bridge(Like the London Bridge), which can be opened when the ships are coming by using one ultra-sonic sensor to detect the distance from the ship and the bridge. And if the ship is within a certain range from the bridge(let's say 30 centimeters), the sensor will send the data to arduino and then transfer it to the distance. And the bridge will filp over. And when the ship drives away. The bridge will filp down again, and will be ready for the next movement.

 

Here is the document of our working process!

 

 

 

1.Sketch:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2.Physical model:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3.Testing H bridge and the physical bridge!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I am making and testing the H-bridge with a simple electrical fan which can control the direction and speed of it

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

H-bridge circuit finished:  Successfully controls the speed of the motor and the direction of the motor. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Sonic sensor connected: detects the distance from the bridge to the object(ship) 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Combinition of the physical model and the circuit!!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4.Arduino code for the bridge

 

int inputPin=2;  // define trigger pin

int outputPin=3; // define echo pin

int motorPin1=4;

int motorPin2=5;

int enablePin=9;

int switchPin1=12;

int switchPin2=11;

int switchPin3=7;

void setup()

{

  Serial.begin(9600);

  pinMode(motorPin1,OUTPUT);

  pinMode(motorPin2,OUTPUT);

  pinMode(enablePin,OUTPUT);

  pinMode(inputPin, INPUT);

  pinMode(outputPin, OUTPUT);

  pinMode(switchPin1, INPUT);

  pinMode(switchPin2, INPUT);

  pinMode(switchPin3, INPUT);//set output

}

 

void loop()

 

{

  unsigned char i,j;

  digitalWrite(outputPin, LOW); // sent a pulse to triggerpin

  delayMicroseconds(2);

  digitalWrite(outputPin, HIGH);  

  delayMicroseconds(10);

  digitalWrite(outputPin, LOW);    

  int distance=pulseIn(inputPin, HIGH);  // read the pulse time

  distance=distance/58;   // thransfer ms to cm 

  Serial.println(distance);   //print the distance                 

  delay(\(\(\(50);  //ultrasonic sensor ends here

 

  

  if (distance <20)

  { 

    digitalWrite(enablePin,HIGH); // ship detected, motor works

    digitalWrite(motorPin1,HIGH);

    digitalWrite(motorPin2,LOW);

    

  }

  

  else

  {

    if(distance>=20)

    { 

    digitalWrite(enablePin,HIGH);

    digitalWrite(motorPin1,LOW);   //ship away, bridge flip down

    digitalWrite(motorPin2,HIGH);

   

    

    }

  

  }

  

  if(digitalRead(switchPin1)==1) // top emergency switch pressed, motor stop

  {

    digitalWrite(enablePin,LOW);

  }

  

  else

  {

  if(digitalRead(switchPin2)==1)// bottom emergency switch pressed, motor stop

  {

    digitalWrite(enablePin,LOW);

   

 

  }

 

  }

 

}

   MIDTERM

 

           H bridge

                &

    London Bridge!!

5. Video_H-bridge

bottom of page