Here is a simple car-parking alarm circuit based on an AVR microcontroller and an ultrasonic module. The circuit will alert you while you are reversing your car for parking, if there is any obstacle, through an audio visual alarm.
Circuit and working
Fig. 1 shows the circuit for the car-reversing alarm. It is built around ATmega328 AVR microcontroller (IC1), 5V regulator (IC2), ultrasonic module HC-SR04, piezo buzzer (PZ1) and a few other components.
ATmega328. The heart of the system is the 28-pin Atmel’s ATmega328, which is an 8-bit AVR microcontroller with 32kB Flash and 1024 bytes of data RAM. It has two 8-bit timers/counters, one 16-bit timer/counter, six PWM channels, 23 programmable I/O lines, programmable serial USART master/slave SPI serial interface, a 6-channel 10-bit ADC and on-chip analogue comparator.
Pins 16 and 17 of IC1 are connected to Trigger and Echo pins of the ultrasonic module. Pin 18 of IC1 is connected to the piezo buzzer. The buzzer starts beeping when distance between the car’s rear and an obstacle is 25cm or less.
Pins 4 through 6 and 11 through 15 of IC1 are connected to LED1 through LED8, respectively, to indicate distance between the car and the obstacle (refer Table I).
A 16MHz crystal oscillator is connected to pins 9 and 10 of IC1 to provide basic clock frequency. Power-on reset is provided by the combination of resistor R10 and capacitor C5. Switch S1 is used for manual reset of the microcontroller.
Ultrasonic transceiver HC-SR04. HC-SR04 ultrasonic transceiver module (Fig. 2) uses sonar to determine the distance of an object, like bats or dolphins do. It offers excellent non-contact range detection of 2cm to 400cm with high accuracy and stable readings in an easy-to-use package.
To determine the distance, pin 2 (TRI) of the module should receive a ‘high’ pulse for at least 10µs. This will initiate the module to transmit eight cycles of ultrasonic burst at 40kHz and wait for the reflected ultrasonic signal. When the sensor detects the reflected ultrasonic signal, it sets pin 3 (Echo) to high. Duration of the reflected pulse depends on the distance from the obstacle. The distance can be calculated as:
Distance (in centimeters) = T/58, where T = Width of pulse at Echo pin in micro seconds
Power supply. 12V DC supply is drawn from the car’s battery, or any other DC source, and converted to 5V using 7805 regulator, to power the circuit, including the microcontroller and sensor module HC-SR04. LED9 is used to indicate the presence of power in the circuit.
Software. The program is written in Arduino programming language and compiled and burnt using Arduino IDE. The software (parkingalarm.ino) is designed to detect an obstacle up to a maximum of 200cm distance.