I am trying to make the fifth project "Mood Cue" presented in the projects book. I noticed all three potentiometers are returning 1023 no matter how I turn them. I made a circuit to test them alone and wrote some code printing their value.
Done. Added both to original post. Posted code and added nice sketch from the projects book. Also ambiguous wires? There's a red one and a black one going of the screen and a red one and a black one coming back in.
No and don't have one. I did use a led to test it and the component does work. Just not as I would have expected. Also sorry for not reading the rules. Next time I'll make sure everything's perfect.
A couple of observations. There's 3 pins on the component and I tested the pins resistance to each other with a led and the 5 V supply from the arduino.
pin 1: power, pin 2: output and pin 3: ground
Between pin 1 and 3 no connection what so ever. No matter what I try.
Between 1 and 2: It actually works. LED Dims and brightens when I turn the knob. However when I remove the LED and hook it up to the analog port A0 it just shorts and spams 1013 on my monitor.
Between 1 and 3: Nothing at all.
Conclusion: No idea. The pins don't work as I expected them too. Maybe there is one power pin, one output pin and one that is there for soldering? Like this:
pin 1: power, pin 2: output and pin 3: nothing.
In the book it said that a potentiometer is a "voltage divider". This appears to be just a linear variable resistor with an extra confusing metal pin.
I tried hooking up the LED and the wire to A0 at the same time and now everything works except it goes between 1023 and 384 because the LED keeps consuming some power.
Wait I bought the arduino basic kit from this site, "crappy book" included. You would think the creators of the product know how their product works. And guys the servo isn't a problem. I've tested it separately and it works like a charm. As soon as I noticed the potentiometer was the problem I disconnected it and tried to solve that issue.
Take the pot out of the equation by connecting a wire between A0 and the 3.3volt pin.
You should see an A/D value of ~685.
And the servo should move to ~120 degrees.
Leo..
It may be me but there seems to be a third wire missing. Or a resistor to form a voltage divider with this pot. Or an INPUT_PULLUP for the same effect (though with the pot connected to +5 that wouldn't have any effect either).
On the picture I see one wire go from what seems to be the +5 to the pot, and one wire from the pot to A1. Then you provide 5V to the A1, regardless of the actual resistance, and you see a reading of 1023 at all times.
Connect the slider to A1, one end of the pot to 5V and the other end to GND and you should get the desired result.
In short...where is the connection between the 3rd pin on potentiometer and ground. The diagram you posted shows it should be there but I can't see it in any of the pretty pictures and without it 1023 is exactly what you'd expect.
Because that's how I wired it up to begin with and nothing happened
I changed the picture and added a sketch so you can see if I screwed it up in some way. Also someone said something about a resistor? Where would you have me connect it?
Resistor between the pot (the connection to A1) and GND. That way you can vary the voltage on A1 between Vcc and whatever midway point the pot and resistor provide (2.5V if it's a 10k pot and 10k resistor - just a voltage divider).
Ok so now It actually works but I have to push on the potentiometer with a lot of force. Are the pins not connecting properly? Thanks It appears that I simply forgot too add a 10k resistor. (which isn't mentioned in the projects book I bought on this website)
"people like you" I don't think you guys are responsible for this book at all. I just didn't expect there to a lot of mistakes. Which isn't that weird when you think about it. To be fair how could I have possibly known that the manual about arduino on the arduino website is full of errors?
And I'm glad you guys could help me. Next step I'm going to solder some wires to the pins because on their own they don't fit properly into the breadboard and don't have a good connection.
I really didn't expect that there would be such poor communication from the "arduino team" to the community.
MateoVanDamme:
Next step I'm going to solder some wires to the pins because on their own they don't fit properly into the breadboard and don't have a good connection.
That probably explains why you have to push it so hard to get a reading.
I really didn't expect that there would be such poor communication from the "arduino team" to the community.
That's economics. Write a book, publish it, get money. Or write a book, ask feedback, spend many hours reading the responses, rewrite it, publish it, get money much later and after much more work.