L298N H-Bridge

Allows for speed and direction control of two DC motors at the same time.

Able to control DC motors that have voltages from 5 to 35 V.

On-board 5 V regulator which can be used as input or output. If VCC < 12 V, one can enable 5 V regulator to use as an output to power Arduino board. If VCC > 12 V, it is recommended not to use 5 V regulator since VCC could damage it.

There is a 2V drop caused by the IC (integrated circuit ), so the voltage at the motor terminals is 10 V which means that full speed won't be achieved by motors.

Enable A and Enable B pins are used to control the speed of the motor.

Input pins 1, 2, 3, and 4 control the switches of the H-Bridge. Input 1 and 2 control one motor and input 3 and 4 control the other motor.

Switches are turned on and off based on logic gates, for example, if input 1 is low and input 2 is high, then motor will spin forward and vice versa.

Ultrasonic Sensor HC-SR04

Uses sonar to determine distance to an object.

It has 4 pins: VCC, TRIG, ECHO, and GND.

Transmitter(TRIG pin) sends a signal, when signal finds object, signal is reflected and received by the receiver (ECHO pin)

TRIG pin needs to be on high state for 10 us in order to send out ultrasonic bursts ( 40 kHz 8 cycle sonic bursts)

Velocity of ultrasonic burst is 340 m/s in air.

Formulas to be used:

- If there is an object at 10 cm away from the sensor, then to measure the time that the sound wave will take to travel from TRIG pin to object, we have to use the following formula:

t = d/v = time=distance/velocity = (10 cm)/(0.034 cm/s) = 294 us.

- ECHO pin will double that time since this pin measures the time to and from the object.

- If a wave takes 100us to bounce back from object, then we use the following formula to calculate the distance to the object:

distance = time * (0.034 cm/s) / 2 = 100 us * (0.034 cm/s )/2 = 1.7 cm