I am reading about analogInput pins on Arduino Uno, and some tutorials are using a potentiometer to demonstrate the ADC and it's range of output which can vary from 0 to 1023 to represent 0 to 5v sensed at the analog pin.
In this tutorial, it is showing that the analog pin is reading 0.
No, a potentiometer is a fixed resistance between begin and end. The wiper just taps off somewhere in between. So if you have a 10k pot and set it to 50% you have 5k from begin to wiper and 5k from wiper to end. Set is to 75% you have 7k5 from begin to wiper and 2k5 from wiper to end. Set it to 0% and you have 0Ω between begin and wiper and 10k between wiper and end. Aka, begin to end stays 10k all the time.
There is another (more accurate) way of drawing a schematic for a pot. That "better" schematic shows that the full-resistance always exists between 5V and ground... as long as it's wired correctly.
The input resistance of the Arduino is super-high so the pot adjustment doesn't affect current flow.
raschemmel:
If it's not needed then why are you posting ?
It doesn't work and an analog input would not be printing "digital value" (for obvious reasons)
If you want our help you are supposed to cooperate. and provide whatever we request.
(it's up to us to decide whether it is relevant after we see it)
Take the time to read the original post. Follow the properly embedded link. All your questions would be answered, if you could be bothered.
@WattsThat Although it's in the link, @raschemmel is right tough. It should not be needed for us to read a lengthy tutorial to help you. This time I just scanned it because it wasn't really needed for the answer. And, like I said, that tutorial makes a basic mistake and thus is wrong
@Wawa I do, and I think newbies should as well, because it's simply wrong. I don't divide/multiply by 99 if I want something in percentage as well... Does not matter if it's close or not. Doing something slightly wrong without gaining anything (for example, simplicity) just makes it harder to understand want's really happening.
I was only trying to say that in this case "5.00" could be 50 times more wrong than using 1023 or 1024.
I just don't understand that people want to see a voltage from something you can't calculate a voltage from (default Aref). Just keep it a digital value, or a ratio.
I do agree that 1024 should be used in most cases though.
Leo..
Even a float division by a power of 2 is faster than division by any other number. The reason is, the mantissa doesn't have to change. The exponent is binary, so the operation is performed by simply subtracting 10 from the exponent. Addition/subtraction is lightning fast.
I don't know if the compiler is really doing that optimization but it certainly should, especially for constant values.