SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By kennyfield
#198086
Hello,

Just having a bit of trouble with the coding challenges from Module 1B. I have added more LED's no problem, just a bit confused by the changing the range portion. Where is the sensor reading that we are supposed to multiply to get to 0-2046 in the code?

Thanks,

Kenny.
By paulvha
#198088
The sensor (potentiometer) voltage output is measured by the analog input. The voltage is translated in a value between 0 and 1023 by the analog input (technically spealing : it is a 10 bits ADC, so 2^10 = 1024).
This value is captured by the program with the line: potPosition = analogRead(A0);

You can do 2 things: either multiply by 2 when reading : potPosition = analogRead(A0) * 2;
OR do add a line after reading : potPosition = potPosition * 2;