Potentiometer questions with ADIN. Please help

Okay, I want to be able to read a potentiometer (so later use an old joystick). The program I have written is:

'Pot test
pttest var word
cr con 13 'for line skip
Start
adin 0, pttest
debug [dec pttest, cr]
pause 500
goto start

The pot is wired by using a standard 3 prong pot with the + & - power on the outside and I/O in the middle, and when hooked up to a multi-meter the power does change when the pot is changed. However, the info in the debug window starts at about 900 and ramps up to 1023 and stays at 1023 no mater how the pot changes. Help me!!! What am I doing wrong?? I have also tried photo resistor, resistors… What now?

I couldn’t see any issues in your code, so I loaded it up to see if there was something I was missing. Using a “pot-with-pins” as your describe, I obtained the expected results - 0 to 1023, corresponding to the position of the potentiometer.

The jumper for pins 0 to 3 was in the “5V” position, and the pot was wired as a simple voltage divider, with +5 and ground on the pot’s outer legs, and the wiper connected to the signal pin.

Similar results were obtained with three different potentiometers: 1.5M-ohm, 100K-ohm, and 10K-ohm. All were wired as described, as a simple voltage divider, using the power pins of the P0 slot of the ABB, jumpered for 5v operation.

In other words: I don’t know what’s causing your problem. :confused:

Well thanks for taking a look… Its been driving me nuts. I suspect that the bot board has something to do with it so I’ll try the Atom on the breadboard.

Thanks again,
-Chris

Can you define the word “power”? If you connect the pot to the bot board then you would be using the pins in the AX0-3 place, not the P0-3 place. By connecting here you are using the vreg on the botboard and there is no chance of providing a voltage more than 5vdc or less than ground, both of whicg can damage the A to D. Remember to install the 5vdc jumper for the Ax0-3 bus to provide the correct “power”. :wink:

That’s an interesting thought: When I tested the code as supplied, I read it as using I/O pin 0 for the A/D conversion, so that’s where I plugged my pot.

Leaving I/O pin #0 open and letting it float, I get precisely the same behavior as described in the initial post. The readings start high (around 700 or so), drift up to 1023, and stay there. If you’re reading I/O pin #0, as you are in the code you provided, but your pot is connected to the Ax0 bus, then you can adjust the pot all day long, and you won’t see the expected results, because you’re reading the wrong pin!

Heh. Good one.

Change: adin 0, pttest …to… adin 19, pttest …and you’ll be reading the Ax0 pin, as I suspect was your original intention.

EDIT: I should probably point out that this was done with the P0-3 and Ax0-3 power jumpers both in the 5V position, not the VS position, and that when I hooked up to the Ax0 header position, it was to the first three pins (ground, +v, and Ax0), leaving the VS pin next to the Ax0 pin unconnected, in order to feed the ADC no more than +5 volts, as mentioned in the above post.