Go Down

Topic: How to get only 1,5 Volts output by using PWM  (Read 299 times) previous topic - next topic

fkydln

Hi everyone,

I need to make a really simple circuit. I am going to light a LED up but LED works between 1,2 - 1,5 volts, so I need to get an output from Arduino and set the output up as only 1,2 volts.

I do not want to use any resistors or something else, I aim to get it via coding.

Will anyone help me by showing an example code or something like that?

Thanks whoever interests.

jremington

#1
Nov 09, 2018, 02:37 pm Last Edit: Nov 09, 2018, 02:39 pm by jremington
If you connect an LED to a port output pin without using a resistor, you will burn out the port pin, sooner or later.

Use a resistor, 150 Ohms minimum on a 5V Arduino.

PWM does not reduce the output voltage, only the time during which the voltage is present.

fkydln

But it does not make sense as far as I know that if you get it the exact voltage like 1 or 2volts, why it would burn the pin out ?

I will do it, connect a 150ohm resistor but it won't prevent burn the led. I still need to reduce any PWM pins' voltage.

Thank you

vffgaston


jremington

#4
Nov 09, 2018, 03:19 pm Last Edit: Nov 09, 2018, 03:20 pm by jremington
Quote
I still need to reduce any PWM pins' voltage.
That is the purpose of the resistor. Look up Ohm's law.

TomGeorge

#5
Nov 09, 2018, 03:24 pm Last Edit: Nov 09, 2018, 03:27 pm by TomGeorge
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Can you tell us your electronics, programming, Arduino, hardware experience?


These links may help you understand.

https://www.arduino.cc/en/Tutorial/PWM


https://www.arduino.cc/en/Tutorial/Fading[/iurl]


https://www.hackster.io/glowascii/fade-an-led-arduino-basics-eebff7


You need to understand that the PWM is 5V pulse and you need the resistor to limit the current when 5V is output.

The fading takes place because of the ON/OFF of PWM, the longer it is ON compared to OFF the brighter the LED will be, and vice versa.

It is standard practice to include a current limit resistor, rather than try and make the output voltage exactly what the LED  is rated at.

Not all LEDs are the same, even if they are from the same batch.

Also if you have excessive current flowing through the LED from the Arduino, not only will you destroy the LED but the output of the Arduino, as it has a maximum current rating of 40mA.

Tom... :) 
PS. Why don't you want to use a resistor?
Everything runs on smoke, let the smoke out, it stops running....

DVDdoug

Quote
I do not want to use any resistors or something else, I aim to get it via coding.
You can't do everything in software...  Some things take special hardware.    

An analogy - You can't dim a light in your house without a dimmer.     A regular light switch only goes on & off and you can't control it with your computer.    Or, you can't get sound of a computer without a soundcard.

Quote
I will do it, connect a 150ohm resistor but it won't prevent burn the led. I still need to reduce any PWM pins' voltage.
The voltage gets divided among the series components and the voltages will  sum-up to 5V.*    The "magic" of LEDs is that they are non-linear (their resistance changes with voltage) and with a resistor the voltage "falls into place".    

The resistor limits/controls the current.  Resistance is the "resistance to current flow".   More resistance = less current, less resistance = more current (Ohm's Law).



* The output voltage may not be exactly 5V, but the series voltages must sum to the total voltage.

Wawa

I am going to light a LED up but LED works between 1,2 - 1,5 volts, so I need to get an output from Arduino and set the output up as only 1,2 volts.
You drive a LED with CURRENT, not with voltage.

If you drive a fixed current through a LED, then as a result you have a volt drop across the LED.

A resistor in series with the LED is an easy way to set LED current.

If you power the LED/resistor from a 5volt Arduino pin (PWM or not), then you can calculate LED current if you know Vf (working voltage) of the LED. In your case about 1.25volt (infrared LED or opto coupler?).
So 5-1.25= 3.75volt is going to drop across the resistor.
If you choose a 220ohm resistor, then you will have 3.75/220= ~17mA LED current.
Leo..

wvmarle

I need to make a really simple circuit. I am going to light a LED up but LED works between 1,2 - 1,5 volts, so I need to get an output from Arduino and set the output up as only 1,2 volts.
As long as the voltage is >Vf, your LED will act like a short.
As long as the voltage is <Vf, your LED will block.
This of course is a simplification of the reality which is less black and white (or block and short in this case) but that's roughly how an LED works and why your idea won't work to begin with.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

6v6gt

You can use pulse width modulation and varying frequencies to generate a given voltage via a digital pin using a simple low pass filter. However, this requirement rules that solution out:
Quote
I do not want to use any resistors or something else, I aim to get it via coding.

wvmarle

You can use pulse width modulation and varying frequencies to generate a given voltage via a digital pin using a simple low pass filter.
Even so you won't be able to drive an LED with such a filtered output. That would need a buffer, such as an OpAmp in unity gain, and that still doesn't solve the current issue of the LED.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

6v6gt

. . .
I will do it, connect a 150ohm resistor but it won't prevent burn the led. I still need to reduce any PWM pins' voltage.
. . .
You can vary the brightness of the LED (fading etc.) with PWM (but not the voltage, hence you need the resistor).
Are you trying to achieve a concrete goal or is this a school exercise ?

lastchancename

Quote
The fading takes place because of the ON/OFF of PWM, the longer it is ON compared to OFF the brighter the LED will be, and vice versa.
Worth mentioning - just to make life more difficult, the dimming will be non-linear...!

The simplest way to get a smooth fade from 0-255 is to use a byte lookup table that corrects the LED brightness to match the flat-slope of the 0-255 span.
Experienced responders have a nose for laziness, (they were beginners once)... expecting the poster to contribute to the learning experience.

ad2049q

I do not think it feasible to do without resistors and stuff.  At the very least you'll need a capacitor.  Try looking up 'audio capacitor, 10 Volts, 100 Microfarad'.  You blip that with 5V not ten, often enough and briefly enough to stay near enough to your desired LED voltage.  To protect your Arduino from damage dumping into an empty capacitor, you should have a resistor.  I'd use 3.3kOhm, expecting 1 mA steady and less than 2mA during the initial turn on surge.  If 1mA is not enough for the brightness of LED which you want then use either an NPN or NFET below the LED and 10 kOhm from the arduino to its base or gate.  The capacitor still goes parallel with your LED.  Further improvements from here are possible.


PWM never does 1.5V at the arduino output pin;  It does 0 and 5 V and spends about a third of its time at 5 V.  

jremington

 
Quote
At the very least you'll need a capacitor.
No, at the very least you need a RESISTOR.

Please do not confuse beginners with misinformation.

Go Up