Sunday, April 10, 2022

ultrasonic sensor with led

 

Step 1: Build the LED Circuit

Build the LED Circuit

Just as you’ve learned from start by wiring up your Arduino and breadboard with power and ground next to the example circuit, then add the the three red LEDs to the breadboard, as shown. These will be the "bar graph" lights for visually indicating the sensor's distance measurement.

    Drag an Arduino Uno and breadboard from the components panel to the workplane, next to the existing circuit.

    Connect the 5 volt and ground pins on the Arduino to the power (+) and ground (-) rails on the breadboard with wires. You can change the wire colors if you want to! Either use the inspector dropdown or the number keys on your keyboard.

    Drag three LEDs on the breadboard in row E, spaced 2 breadboard sockets apart. You can change the LED color using the inspector that pops up when you click on each one.

    Use a 220 Ohm resistor to connect each LED's cathode (left leg) to the ground rail (black) of the breadboard. You can change a resistor's value by highlighting it and using the dropdown menu.

    Connect the LED anodes (right legs) to digital pins 4, 3, and 2 on the Arduino. The LED anode (+) is the terminal that current flows into. This will connect to the digital output pins on the Arduino. The cathode (-) is the terminal that current flows from. This will connect to the ground rail.

    Let's measure distances with an ultrasonic rangefinder (distance sensor) and Arduino's digital input. We'll connect up a circuit using a breadboard and use some simple Arduino code to control a single LED.

    You may have already learned to read a pushbutton and PIR motion sensor with Arduino's digital input, and we'll build on those skills in this lesson.

    Ultrasonic rangefinders use sound waves to bounce off objects in front of them, much like bats using echolocation to sense their environment. The proximity sensor sends out a signal and measures how long it takes to return. The Arduino program receives this information and calculates the distance between the sensor and object.

    Find this circuit on Tinkercad

    Explore the sample circuit embedded here by starting the simulation and clicking on the proximity sensor. This will activate a highlighted area in front of the sensor with a circle "object" inside. You may need to resize the view if the circle is off screen.

    Click and drag the "object" circle closer and further away, noticing the changing distance values on screen. More LEDs will light up the closer you get to the sensor.




    please comment on youtube so that you will get the code 



    No comments:

    Post a Comment

    dc motor with encoder arduino

    How to control dc motor with encoder: Arduino DC Motor Speed Control with Encoder-  I have been using different types of stepper motors, Ser...