Voltage measuring over a led

Hi, i am measuring the voltage over a led, i connected it to the arduino board a in and ground, i use the pullup resistor, but somhow if i disconnect the batterie the led still burns

what am i doing wrong??

void setup()
{
  Serial.begin(9600);
  pinMode(A7, INPUT_PULLUP);
  pinMode(A9, INPUT_PULLUP);
  pinMode(A11, INPUT_PULLUP);
//  pinMode(40, OUTPUT);
}

void loop()
{
//  analogWrite(40, 255);
  int analog_value = analogRead(A7);
  int analog_value1 = analogRead(A11);
  int analog_value2 = analogRead(A9);
  float input_voltage = (analog_value * 5.000) / 1024.000;
  float input_voltage1 = (analog_value1 * 5.000) / 1024.000;
  float input_voltage2 = (analog_value2 * 5.000) / 1024.000;
  Serial.print(input_voltage);
   Serial.print(" ");
  Serial.print(input_voltage2);
   Serial.print(" ");
  Serial.print(input_voltage1);
   Serial.println();
//    Serial.println();
// Serial.println();

delayMicroseconds(700);
 // analogWrite(40, 0);
 // delayMicroseconds(23);
}

connected it to the arduino board a in and ground

Can you be more precise?
Which type of arduino are you trying to destroy?

normal arduino atmega 2560

i do have a capacitor over the led, but when i disconnect the batterie to the led the capacitor keeps loading up

Post a complete hand drawn wiring diagram, including any connections to batteries and/or your PC.

when i disconnect the usb the led goes off

picture:

https://image.jimcdn.com/app/cms/image/transf/dimension=1280x10000:format=jpg/path/s47bcde87e3788f11/image/ia06ec28f1976377f/version/1543637725/image.jpg

Your picture:

Where is the battery?
No current limiting resistor?

That is a great way to destroy your Arduino.

You have no current limiting resistor in the LED, the capacitor is useless and the raw pin does not have enough current capacity to drive that coil. Finally you have no reverse biased diode across the coil.

how can i distroy my atmega with a circuit that has no batteries and an empty capacitor???you are talking shit thanks anyway 4 the time but this time you are wrong

only thing i can think off that my coil collects ambient noise and that's what is charching the capacitor, or i do som wrong in the programming

sow my question is can a a9 input give voltage with a pullup risistor, i thought thats what the pullup resistor is 4

Your microcontrolers pins can only emit a certain current (up to 40mA peak - keeping it below 20mA is a good practice) and if you try to draw more than this, you’ll fry that pin.

If you power your LED through a digital pin, then as a LED is current driven and will want to draw all the current it can from its source you are putting that pin at risk (As you power your arduino through USB which gives probably 500mA available)

That’s why (most) drawings with a LED include a resistor in series. In a nutshell U = RI => U is 5V so with R you limit the current that will flow

In the same way à pin can sink up to a max current (40mA, not going over 20 recommended). how much current will flow in your circuit to the pin if the thing with 2 lines and + - is a battery ?

—-

Back to the question - where is the battery and/or the cap ?

dude please read i use the pin 4 input with a pullup risistor i am not lighting a led with an output, please read

peeniewallie:
dude please read i use the pin 4 input with a pullup risistor i am not lighting a led with an output, please read

Dude please document what you do better, read the docs and answer questions you are being asked if you expect any further help.

There is no pin 4 documented anywhere in your drawing or code

How are you lighting the led ? where is the current limiting R ?

You mention a battery and a cap, (i do have a capacitor over the led, but when i disconnect the batterie to the led) ==> what is what in you drawing? It’s unclear and being asked for the 3rd time

The doc mentions

Pull-up resistors

The analog pins also have pull-up resistors, which work identically to pull-up resistors on the digital pins. They are enabled by issuing a command such as

pinMode(A0, INPUT_PULLUP); // set pull-up on analog pin 0
Be aware however that turning on a pull-up will affect the values reported by analogRead().

as well as

There are 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed by setting the pinMode() as INPUT_PULLUP. This effectively inverts the behavior of the INPUT mode, where HIGH means the sensor is off, and LOW means the sensor is on.

The value of this pullup depends on the microcontroller used. On most AVR-based boards, the value is guaranteed to be between 20kΩ and 50kΩ. On the Arduino Due, it is between 50kΩ and 150kΩ. For the exact value, consult the datasheet of the microcontroller on your board.

When connecting a sensor to a pin configured with INPUT_PULLUP, the other end should be connected to ground. In the case of a simple switch, this causes the pin to read HIGH when the switch is open, and LOW when the switch is pressed.

The pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LEDs in a project seem to be working, but very dimly, this is likely what is going on.

What don’t you get from that doc?

peeniewallie:
sow my question is can a a9 input give voltage with a pullup risistor, i thought thats what the pullup resistor is 4

Wut?? Can u make more scents pls. Without any further explanation on this topic, the answer is yes, an input pin can give voltage with a pullup resistor. But it's not for providing any driving voltage, which is what you might be trying to do, but didn't explain it very well. A pullup resistor is there to provide a positive voltage for an unbiased input. That way a floating input will read HIGH to an Arduino.

The resistor is internal to the chip, and has a value between 20K and 50K ohms. Trying to power an LED with the current you get that way is ... stupid.

peeniewallie:
how can i distroy my atmega with a circuit that has no batteries and an empty capacitor???you are talking shit thanks anyway 4 the time but this time you are wrong

Wow what a response from someone asking for help.
Now I could take four courses

  1. Ignore you and let you stew in your own ignorance.
  2. Send you abuse back
  3. Report your post to a moderator for personal abuse and have you banned for a short time.
    or
  4. Despite your unworthiness for help try and educate you.

I will try option 4 first.
Clearly you don't know what you are doing or you would not be asking for help. Yes a pull up resistor on the pin 9 input will light an LED, how come you didn't know that if you are so smart?

"empty capacitor" how can you have an empty capacitor if it across an LED that is lit? You can't the capacitor is not empty, anyone with an ounce of sense would know that woudn't they?

It is true you have not explained what you want to do so you are not so good at that bit are you?

If you put a 9V battery across your coil there is a good chance of damaging your Arduino, do you concede that? Do you know why?

However as you say you don't have a battery just a coil. A coil can generate / produce a voltage on it due to electromagnetic pickup. Either through propagation of an EM wave or through waving a magnet in front or inside it. That voltage would be an AC signal which involves a positive and negitave alternating voltage. As one end of the coil is connected to the Arduino's ground that means the voltage presented to pin 9 would include a negitave voltage. A negitave voltage can damage an input pin.

Less of the attitude when asking for help.

Ignore the troll -- complete waste of time.

if I may continue ChrisTenone's above post :
Not only the led will not light up because of 20k resistor but also from 0 ohm of the coil and from 0 Ohm of a discharged capacitor.

also let me define phrase "dude please read i use the pin 4 input with a pullup risistor ..." above

means ..i use pin F O R input..

excellent " programming Q "
excellent comm
someone remove it from the forum? No technical basis.

demkat1:
also let me define phrase “dude please read i use the pin 4 input with a pullup risistor …” above

means …i use pin F O R input…

LOL… kids typing in SMS language… thanks 4 the translation :wink:

Where has scientific appetite for accuracy and precision gone?..

Lost in space...