hey Michael, that was a very good tutorial, I had no idea that the arduino was that sensitive to the high and low state. not to mention that some where in the middle it's so iffy, it can go either way. Robert is right you didn't show how you connected to pin 2, it would be good if you could send him a reply on how you connected it. thanks mk
8:46: Just a quibble, but the analog sensorValue is multiplied by (5 / 1023) to give voltage. Wouldn't it be more intuitive to first divide it by 1023 to give its value as a proportion of the max reading and multiply *that* by 5? Also, since sensorValue has 1024 possible values, it makes sense to use that instead of 1023. And since sensorValue is 0-indexed, it should be incremented by 1 to get the voltage: voltage = (sensorValue + 1) / 1024 * 5 Computing this verifies it is correct. Inputting 511 (the middle sensor value) gives exactly 2.5: 2.5 = (511 + 1) / 1024 * 5
No diagram showing applying voltage to pin 2. Did you just connect a jumper between analog pin 0 to digital input pin 2? Or does there need to be a resistor? Also, what is the proper value of the potentiometer? (I'm a newbie...)
Robert Cowan Hi Robert. Great question and I should have pointed that out in the video! If you connect the middle pin of the potentiometer to pin 2, this will do the trick. Just make sure that pin 2 has been set to an Input using the pinMode() function. Hope this helps and have a good one!