Let’s interface an ultrasonic sensor and a lighting system! In this project, we’re going to design a system that uses an ultrasonic sensor to trigger a lighting system and an LCD as an information screen.
To show the system in action, we’re making a non-contact garage parking sensor system using a C8051 microcontroller development kit and the Simplicity Studio IDE. The measured distance will be displayed on the LCD screen, and two LED floodlights will activate as a function of the distance between the vehicle and the sensor.

System Requirements and Applications
The system we’re building here has the following features and requirements:

Proximity/detection sensor: The ultrasonic distance sensor serves as a proximity/detection sensor. When an object is detected, it must constantly, in real time and with minimal time lag, measure the distance to a moving object.
Small in size: The system should not occupy too much space in the garage or wherever else it is used, and it should fit within a reasonably sized enclosure.
Bells and whistles, and/or lights: The system must have a noticeable alarm for announcing when an object has reached its ideal/targeted location.
No AC voltage: It must be free of AC voltage (for safety and mobility reasons). Using 12 V as the supply voltage allows the system to run from an off-the-shelf AC-to-DC converter or from a 12 V battery.
Based on these parameters, you should be able to incorporate this system into a number of different applications:

Swimming pool or home garden detection system for sending an alert when the curiosity of children and/or pets gets the better of them…like that never happens.
To help prevent your friends and neighbors (or family members!) from stealing the leftover pizza and beer from your fridge—they are free to roam your kitchen, but if they get too close to the fridge…SOUND THE ALARM!
Do you like to camp and enjoy the great outdoors? A battery-powered system could be used to help prevent your young children from getting too close to a stream when you’re reading your book or casting that fishing line.
At the end of this project, I’ll show you a sensing system for a garage in action.”

Link

Related Content