 Arduino Nano not putting out voltage?

Hey, i'm totally new to Arduino and i'm wondering what am i doing wrong. So basically i wanted to put out voltage on one of the digital pins to light up an LED. That doesn't work. So i tried to measure the voltage from the digital pin by connecting it to an analog input.

My code is like this:

int out = 3; int in = A7;

void setup() { pinMode(out, OUTPUT); pinMode(in, INPUT); Serial.begin(9600); }

void loop() { digitalWrite(out, HIGH); int value = analogRead(in); Serial.println(value); delay(200);

}

I connect digital pin 3 to analog pin 7. But now when looking at the serial monitor i always get values between 260-270. What am i doing wrong?

Maybe you've blown the pin. Did you remember to put a resistor in circuit when you connected the LED?

Yes i put in a resistor. Actually it's the same with other pins and other types of applying voltage to it. So when nothing is connect to the analog pins, they all measure a value at about 250. I tried connecting a piezo to a pin, also with 1megaohm resistor, and when i hit the piezo the value only increases lightly, i get about 280 or so.

So maybe it's the analog pins?

Another question, if i just connect the 5V pin to the LED with a resistor in between, and then to GND, should the LED light up?

Yes the LED should light, assuming the resistor is less than 1 kOhms or so. What reading do you get if you connect A7 to +5 V?

Hi, Also make sure that you have the LED connected the correct way. The long leg is the anode and the short is the cathode, anode is positive end, cathode is negative end.

Tom..... :)

I used a 150 Ω resistor. So cathode gets connected to GND?

Still its not working. AWOL, you mean directly connecting A7 and 5V pins, no need for grounding?

Yes I mean connecting A7 to +5 V and absolutely not connecting +5 V to ground.

Okay, so i directly connected them and i still get quite a constant value of 240.

Have you got a pot you can connect, to vary the voltage? It sounds like the ADC is knackered.

Hi,
Change
pinMode(in , INPUT);

to
pinMode( A7 , INPUT);

Tom… TomGeorge: Hi, Change pinMode(in , INPUT);

to pinMode( A7 , INPUT);

Tom.... :)

That should work either way. But there may be some reason why the compiler works better with the suggested solution.

You don't have to set the pinMode for an analogue input pin, the analogRead does it automatically.

I just figured out it's because of the connection. I'm using the Arduino nano on breadboard, and always made the connection with the breadboard. But when i directly hold a wire from 5V to A7 it i get 1023. So there are these 2 rows with 15 pins delivered with the nano. I put the rows of pins in my breadboard and then the arduino on top. But the pins are coming out about 2 milimeters through the holes of the arduino, and it sits a bit loose, therefore the current probably isn't transmitted correctly. So when i tilt the arduino a bit on its position on the pins, i get 1023 as well, so there is a connection. What can i do, can i solder the pins together with the arduino, or could that damage the chip?

If you want reliable connections, you have to solder.

Okay, so i soldered the pins together with the nano itself and now outputs and inputs are working just fine. Thanks for your help!