# Problem With Analog Inputs when Arduino is Externally Powered

**URL:** <https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113>\
**Category:** General Electronics\
**Created:** [January 23, 2023, 2:11am UTC](https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113 "2023-01-23T02:11:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sloe46](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sloe46](https://forum.arduino.cc/u/sloe46)\
**Post date:** [January 23, 2023, 2:11am UTC](https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113/1 "2023-01-23T02:11:26Z")

</div>

Hello, I have been doing some prototyping with Arduino Nano. The goal is to read an analog voltage and if that reading is less than or equal to 2V I would like to turn on LED. I am reading the analog input from a power source that I am varying from 0-5V across a 1kOhm resistor. I was able to successfully do this when I power the Arduino from the USB 2.0 port. However, when I try to power it with a 5V regulated source, from a 12V to 5V Linear regulator(L7805), the readings are not correct as the LED powers on when the Analog input is less than or equal to 1V. I noticed that when I bypass the regulator and power with the 12V source all is well. I have attached some tinkerCad images of the when it is working via the USB Power. The only difference when it does not work is that I am powering the Arduino via the Vin and GND pins from the L7805 Vout and GND pins. I am using a 12V battery and an Arduino Nano but couldn't include that. Any help is appreciated.

```cpp
int controlPin = 3;
int sensorPin = A2;
float sensorValue = 0.0;
float voltageValue;
void setup() {
  // put your setup code here, to run once:
  //Serial.begin(9600);
  pinMode(controlPin, OUTPUT);
  pinMode(sensorPin, INPUT); 

}

void loop() {
  // put your main code here, to run repeatedly:
  sensorValue = analogRead(sensorPin);
  voltageValue = (5.0 / 1023.0) * sensorValue;
  //Serial.println(voltageValue);
  delay(500);

  if (voltageValue < 2.0) {
    digitalWrite(controlPin, 1);
  }
  else {
    digitalWrite(controlPin, 0);
  }

}

```

 ![WorkingWithUSBPower](https://europe1.discourse-cdn.com/arduino/original/4X/a/4/2/a420215c3de88f8f0e367241102a6284e4dc3c0e.jpeg)

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [January 23, 2023, 2:15am UTC](https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113/2 "2023-01-23T02:15:20Z")

</div>

Is this only in simulation, or a real circuit?

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [January 23, 2023, 2:17am UTC](https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113/3 "2023-01-23T02:17:28Z")

</div>

The Vin pin needs 7 to 9V.

5V will not work on Vin.

---

<div class="post-metadata">

**Author:** ![sloe46](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sloe46](https://forum.arduino.cc/u/sloe46)\
**Post date:** [January 23, 2023, 2:35am UTC](https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113/4 "2023-01-23T02:35:13Z")

</div>

Thank you. I never powered an Arduino externally and since the USB operates at 5V. I assumed 5V would be sufficient. The data sheet clearly states other wise. Much appreciated.

---

<div class="post-metadata">

**Author:** ![anon85221860](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anon85221860](https://forum.arduino.cc/u/anon85221860)\
**Post date:** [January 23, 2023, 2:52am UTC](https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113/5 "2023-01-23T02:52:00Z")

</div>

5V is sufficient - placed at the 5V pin (terminal).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 22, 2023, 2:53am UTC](https://forum.arduino.cc/t/problem-with-analog-inputs-when-arduino-is-externally-powered/1081113/6 "2023-07-22T02:53:02Z")

</div>

Closed on July 22, 2023, 2:53am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
