Potentiometer Problems

My team is having trouble with our potentiometer. We have all three leads conected and we have tested them for voltage and resistence, and both turned up to be fine. We have checks everything over, but we just can’t get the values to print to screen. We are using easyc pro but I typed out the code:

#include “Main.h”

void main( void )
unsigned int PotValues;

while (1)
PotValues = GetAnalogInput(1);

Can anyone help me here? This just does not seem to be working, We compared this programto those of last years but still has not turned anything up, we also tried using MPLab but still nothing. If anyone can help us out, we would really appreciate it!:confused:

Well, firstly, are you sure you have the wires connected correctly. There should be a diagram of some sort on the pot itself, that looks like this.


If the diagram isn’t on there, the offset pin on the pot will be number 2. Pin 1 goes to white, 2 to red, and 3 to black, on a PWM cable from an Analog Input.

Other than that, I don’t use easyc and I couldn’t tell you if that’s the problem.

Don’t you mean 1 to red, 2 to white, and 3 to black, or 1 to black, 2 to white, 3 to red? Or did I confuse something. I think if you do this, you will release some magic smoke. Please correct me if I’m wrong, I have our potentiometer connected this way and I’m about to connect it tomorrow. Please Please reply.

Your description is confusing. Are you actually having problems with a potentiometer, or is your problem right now just with printing the value being read? It seems to me that your question actually belongs in the Programming forum where someone who knows EasyC might be able to help.

one thing that I can see that might be problem is you are locking yourself in an infinite while loop which might not be allow the program to print anything.

thats just what i see but, I have not worked with easy c.

With EasyC you don’t need to worry about your loop speed like in MPLab, the while(1) loop is fine.

Isn’t the potentiometer built in to EasyC, there should be a block under Inputs(I think) that says potentiometer that you can use that may help, although the way you are doing it should work fine.

You ae correct: One “end” of the pot goes to black, the other “end” goes to red - this puts a 5 volt potential across the entire pot. You then connect the Wiper of the pot to the white, so the RC can read the voltage at the wiper contact (which varies from 0 to 5 volts). Using the diagram, black goes to 1 or 3, red goes to 3 or 1, and WHITE goes to TWO.


Why do I always screw things up when I’m trying to help someone? Yes, your wiring is right. 1 to red, 2 to white, 3 to black. There won’t be any smoke if you do it incorrectly, though.