Page 1 of 1

SIK V4.0 1B Coding Challange

Posted: Sun Jan 28, 2018 7:50 pm
by kennyfield
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.

Re: SIK V4.0 1B Coding Challange

Posted: Mon Jan 29, 2018 5:34 am
by paulvha
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;