I set up the setup and program (slightly altered to my own liking)
I am not new to the world of programming but new to engineering anf arduinos. I am using the exact same Elegoo kit as he is and I haven't noticed any problems yet, the only thing I have found weird is the potentiometer. My potentiometer for some reason, upon being plugged in, gives me two different scenarios.
I have it set up to give values from 0 to 5 (as in volts) instead of 0 to 1023. I just think it is simpler for me to understand that way.
Scenario One: The number usually is 5, but sometimes it gives random values, like goes from 5 to 2 in 100 milliseconds, and back up to 5
Scenarip Two: This one is more commo, and what happens is (without touching the dial) the value will fluctuate from 5 to 0 and back up to 5, it will stay at 5 for a bit and do the same over and over, turning the dial has minimal effect if anytbing.
I really need to know if my potentiometer is working for a school project I have coming up, and I want to know if mine is broken, or if I am using it incorrectly somehow. Feel free to ask questions, I am desperate. Thank you guys!
p.s if my current one is broken/ bad quality, what brand would you recommend me getting a replacement for/
Also please do not use advanced language because I am new to this arduino thing and so far am enjoying it, I just want to ensure that I understand the problem and know how to solve it next time.
filyxx:
I set up the setup and program (slightly altered to my own liking)
So rather than posting a link to a video of something that isn't what you are using please post YOUR program code and a schematic or at least clear picture of YOUR setup.
My first guess is that you're trying to plug the potentiometer directly into a breadboard and it isn't making good connections. Second guess, there's something wrong with your code.
raschemmel:
Your 100mS delay is too short.
Try increasing it to 300 to 500 mS.
Thank you! Someone else said it wont work but I will definetely try it, it's worth a shot. As long as my potentiometer works and I can figure out what the problem was idc
FYI, the standard procedure is to use a loop to take 10 measurements and then add them up and divide by 10
to get the average. It's called sample averaging.
raschemmel:
FYI, the standard procedure is to use a loop to take 10 measurements and then add them up and divide by 10
to get the average. It's called sample averaging.
I see, but I still am wondering if the potentiometer is broken or not. Thanks for the heads up though!
Breadboard connections are usually OK; however the pins on the back of your pot may be too short to make a good connection. So maybe soldering wires to them would improve the connection.
I've tested your code and made some modifications as you will see to take 16 readings and average them
//int readV = A0;
#define readV 0
int readVal;
float V2;
int wait = 100;
String message = "Potentiometer Voltage is ";
void setup() {
Serial.begin(57600); //9600 was good for teletypes, a bit unnecessary today!
}
void loop() {
readVal = 0;
for (int i = 0; i < 16; i++) {
readVal += analogRead(readV);
delay(10);
}
readVal = readVal >> 4; //divide by 16
V2 = (5. / 1024.) * readVal;
Serial.println(message + V2);
delay(wait);
}
The code is working fine so either you have a bad pot - not unknown - or poor connections.
johnerrington:
Breadboard connections are usually OK; however the pins on the back of your pot may be too short to make a good connection. So maybe soldering wires to them would improve the connection.
Okay I'll definetly try it. But is it possible to do it in a way where I don't solder? If not I can probably find a way to do that.
Here is my pot, after I read what you said and checked the middle pin is definetly smaller than the input and grounding pin. For some reason when I add two images it gives me a "too large" error so I just attached the bets image out of the three I had taken
Okok I know you didn't want google drive links but the image system is glitching out for me, I am senging this message because the image didnt show up on the previous post, I am going to try it again, but I am sending a google drive link just incase. Sorry!