Distance Sensor + 4 Digit, 7 Seg Display

Introduction: Distance Sensor + 4 Digit, 7 Seg Display

Use a distance sensor and see the distance of objects on a seven segment display. You can also see a servo get move more towards the left as an object gets closer. A red LED will tell you if your too close and a green LED will tell you if your too far.

Supplies

- 1 x 5641AS 4 Digit, 7 Segment Display

- 2 x 330 Resistor

- 1 x Ultra Sonic Distance Sensor

- 1 x 180 Degree Servo

- 1 x Red LED

- 1 x Green LED

- 1 x Arduino

- 2 x Bread Board

- Wires

Step 1: 4 Digit, 7 Segment Display

Pin 6,8,9 and 12 to a pwm pin. These pin are the power for each individual display. The arduino will send power to the first display's pin and send a high or low signal to each segment pin (that being the lettered ones on the diagram). Than a number will appear for the first display. Than arduino will turn that display off and turn on the second, than third and fourth (which not being used). The displays will turn on and off so quickly that it just seems like one large number.

Step 2: Distance Sensor

The distance sensor has 4 pins which are VCC, Trig, Echo and Ground. The VCC just needs to be supply voltage between 5 and 7.8 volts. The ground needs to be 0 volts. The trig pin needs a pwm signal which will rapdily turn on for a few milliseconds and than turn off. This signal will turn on the the transmitter which will send a ultrasonic wave to an object. This wave will than be sent back to the receiver which will turn off a timer. This time will than be converted into a pwm signal which the arduino converts into a distance.

Step 3: Servo and LED

A servo has 3 pins that being ground, VCC and signal. The ground will be 0 volts, the VCC will be between 5 to 10.6 volts of supply voltage. The signal pin will take in a pwm signal which will be between 1 milliseconds and 2 milliseconds. If the pwm signal is 1 milliseconds than the servo will have an angle of 0 degrees. Whereas, if the pwm signal is 2 milliseconds than the servo will have an angles of 180 degrees. However, in the code the a distance just has to be converted into an angle and the arduino will create the pwm signal already.

The LED works when the distance of the object is less than 15 cm whereas a green LED will turn on when the distance is greater or equal to 50 cm. These LEDs work by having the anode (positive) connect to the signal pin of an arduino and the cathode (negative) connect to the a 330 ohm resistor which is connected to ground.

Step 4: Code

Some of the pin numbers may be different compared to the diagram. Moreover, if you don't like the speed of the display you could always change the value of the variable DISPLAY_SPEED to a different number.

Be the First to Share

    Recommendations

    • Halloween Contest

      Halloween Contest
    • Space Contest

      Space Contest
    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge

    Comments