First of all , while it is technically correct that when the pin touches the nail " a current will flow",
it is not correct to say that because the input impedance of an analog input is in the order of 100Mohms
and the “current” (as you say) that “flows” is in the order of 120 nA. (120E-9 Amps).
We don’t say "current flows in a analog input " because it’ just sounds stupid or ignorant to say that when
the amount of the current approaches zero.
It’s an analog input. The function of an analog input is NOT to measure CURRENT , but to measure VOLTAGE, so we only talk about VOLTAGE when discussing analog inputs. Everyone knows the current is
so close to zero it’s not worth mentioning, and shouldn’t be since an ADC measures voltage, not current.
We say "The voltage measured is 1023 counts*(5/1023)
(that’s 4.88mV /per count)
So if you read 1023 counts
1023 * (5/1023) = 5V
But before we go any further, I should point out that anyone you ask is going to say:
"Why in hell are you using an analog input pin to measure a voltage you already know ?
Why not just connect the pin to DIGITAL Inputs and use digitalRead() ?
That’s the ONLY approach that makes any sense for this application.
I assume that the only reason YOU are using analog inputs is simply lack of
experience with arduinos.
To answer your question about the resistor, your analog inputs are constantly connected (pulled down)
to 0V by the resistor , which serves as a pulldown resistor.
The pulldown resistor stablizes the input current of the analog pin such that when you touch it , with the pin, you are connecting the resistor to 5V, so there are two current paths, one through the resistor at a rate of about 5V/1000 ohms = 5mA , and the second through the wire to the analog pin at about 120nA.
The resistor simply makes it more stable. If you plug a wire in instead of holding the pin so that the analog pin is connected to 5V with NO resistor from 5V to GND, and your hand is not touching it, then
it should be a stable reading of 1023 counts. If your connection from 5V to the analog pin is a good
breadboard connection, it should be a stable reading. I have done this many times to test analog inputs I thought I might have damaged. Maybe your holding it while trying to read it.
So , that being said, let’s forget about the analog input approach.
Use digital inputs. Matlab accepts boolean inputs so you can use the 1s or 0s outputted by digitalRead().
Are you using analog pins because you want to use the serial monitor capture file as an input file for
How are you processing the data ?
You left that part out. You take readings and then what do you do with those ?
Are they serial monitor capture files used as input files for matlab ?
I have Matlab and I know it accepts both text and .csv files so serial monitor capture file could be
used as a matlab import file.