0

I want to use a distance sensor like the HC-SR04 to power a stop light like parking sensor for my garage. I have seen a lot of tutorials on how to use the HC-SR04 to power a single LED and found the schematic below on how to control up to 14 LEDs by hooking them onto the 5v and using a transistor. I have added a box where I would hook the sensor in. My question is, would it work if I had the sensor hooked into the 5v as well. The plan is to have 3 sets of 14 LEDs and have one set on at any given time. I plan on using an Arduino Uno. Schematic

  • Thanks for all your help and encouragement. The link arduino.cc/en/Main/ArduinoBoardUno says that there is a 5 v output straight from the board's voltage regulator. Is that not separate from the output pins? – user2969 Jun 15 '15 at 5:50
  • If you power your Arduino through the Vin pin, the current limit will be given by the 5 V regulator. According to it's datasheet, it's actually a power dissipation limit: the higher the Vin voltage, the lower the current limit (power = current × (Vin − 5 V)). Check the thermal pad size on your Arduino and refer to Fig. 21 (p. 8) of the datasheet. – Edgar Bonet Jun 15 '15 at 7:59
  • Edgar, would I have enough current to run those LEDs and a distance sensor from the 5 v pin if I had a 9v 1A charger? – user2969 Jun 15 '15 at 13:04
  • @user2969 If you hooked the power to VIN and GND, then that should be more than enough for the HC-SR04 and a handful of LEDs. On a side note, please ask another question if you have another question. Thanks! – Anonymous Penguin Jun 15 '15 at 13:51
  • 140 mA × (9 V − 5 V) = 0.56 W. The regulator can dissipate up to 0.6 W with the minimum pad size. Then, assuming the Arduino complies with this required minimum, you should be (barely) fine. – Edgar Bonet Jun 15 '15 at 14:37
0

If I am understanding correctly, you have 3 LEDs ... call them A, B and C (the fact that they are a group of 14 LEDs is a red herring). As a function of the distance measured, you want ONE of LED A, B or C lit.

Since you are using an Arduino, you have GPIO pins. Connect a different GPIO to each of A, B and C. You can then write an application that senses the distance (as measured by the HC-SR04) and depending on the distance returned, have a set of "if" statements which will choose which of the GPIOs to set HIGH and the others LOW. The GPIO set HIGH will switch on the corresponding LED.

In fact, its going to look a lot like this Instructable:

http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/

  • I think you are understanding. I was just concerned about running both the LEDs and the distance sensor off the 5v output. I didn't think it would matter as long as I always had one set of lights on so the sensor would have power – user2969 Jun 15 '15 at 3:35
  • The main difference with the link you posted is the LED is being powered by the GPIO. I was under the impression that the GPIO pins wouldn't supply enough voltage (or current, I'm not sure... I really am just starting). Here is where I got the original schematic: electronics.stackexchange.com/questions/78096/… – user2969 Jun 15 '15 at 4:04
  • The maximum amount of current through a GPIO pin is rated at 40mA. If an LED sinks about 20mA then you can series wire 2 LEDs. If you need to power more LEDs when a GPIO pin goes positive, then you have choices. You can use a transistor or something like a 4050 IC (drive up to 6 higher current devices). The maximum output current through an Arduino is 200mA ... so if you are to power everything from the Arduino, you need to ensure that you are less than this in total. – Kolban Jun 15 '15 at 4:17
  • Which brings me back to the schematic above. The LEDs are powered via 5v connection, which if I have read everything correctly, can support greater current (900 mA) because it doesn't run through the Arduino – user2969 Jun 15 '15 at 4:21
  • In the schematic, we see one GPIO controlling a bunch of LEDs which is not what I understand the plan to be. The schematic also shows that the LEDs are being powered by the output 5V from the Arduino. The Arduino spec says that it can source a max of 200mA. Now, if you need 900mA then you connect a source that does NOT come from Arduino and give both the Arduino and the driving source a common ground. – Kolban Jun 15 '15 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.