Offline
Newbie
Karma: 0
Posts: 17
|
 |
« on: October 01, 2012, 01:53:18 pm » |
I tried all the examples (the basic examples ) using analog input with potentiometer, even changed to a resistor but none of them worked, the serial monitor always show 1023, and in other examples using leds, the potentiometer doesn't change led brightness. Sorry for my bad english.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #1 on: October 01, 2012, 02:20:53 pm » |
You need to tell us exactly what you wired up, and how you wired it.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #2 on: October 01, 2012, 02:41:19 pm » |
You need to tell us exactly what you wired up, and how you wired it.
/* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */
// the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); }
// the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } Following this image:  Using 110k potentiometer. But the serial always showed 1023, even using the potentiometer at the mimimum. Also tried this example: http://arduino.cc/en/Tutorial/AnalogInOutSerial , but the potentiometer didn't changed led. And i used other potentiometer but also, no sucess..
|
|
|
|
« Last Edit: October 01, 2012, 02:43:16 pm by rgPaiva »
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #3 on: October 01, 2012, 02:44:23 pm » |
But the serial always showed 1023, From that code? Really?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #4 on: October 01, 2012, 03:02:58 pm » |
Well the picture doesn't tell us if you correctly identified the pot's wiper terminal to wire to the analog input pin. You should take a multimeter voltage reading from ground to the input pin to see if the voltage does change from 0 to +5vdc as you move the pot's know through its range. Also 110K ohm pot is awful large value, analog input pins work best with 10k ohm or less of source impedance.
Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #5 on: October 02, 2012, 01:32:48 pm » |
Well the picture doesn't tell us if you correctly identified the pot's wiper terminal to wire to the analog input pin. You should take a multimeter voltage reading from ground to the input pin to see if the voltage does change from 0 to +5vdc as you move the pot's know through its range. Also 110K ohm pot is awful large value, analog input pins work best with 10k ohm or less of source impedance.
Lefty
I correctly identified the pot's outputs, because i tested it on the arduino uno today , and it worked perfectly, the same code, all works fine with uno but not with this mega 2560.
|
|
|
|
« Last Edit: October 02, 2012, 01:35:54 pm by rgPaiva »
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #6 on: October 02, 2012, 01:36:04 pm » |
Your Fritzing diagram. (I hate 'em) doesn't appear to me to show a Mega.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #7 on: October 02, 2012, 01:54:06 pm » |
Well the picture doesn't tell us if you correctly identified the pot's wiper terminal to wire to the analog input pin. You should take a multimeter voltage reading from ground to the input pin to see if the voltage does change from 0 to +5vdc as you move the pot's know through its range. Also 110K ohm pot is awful large value, analog input pins work best with 10k ohm or less of source impedance.
Lefty
I correctly identified the pot's outputs, because i tested it on the arduino uno today , and it worked perfectly, the same code, all works fine with uno but not with this mega 2560. I can only tell you how I would approch troubleshooting this symptom. I would first take a meter and measure the actual voltage applied to the pin and see if it tracks with turning of the pot. That would give me a good indication to next look at wiring or the sketch code. If you don't own a meter you should get one soon, as anyone building even simple projects using an arduino should. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #8 on: October 02, 2012, 02:10:11 pm » |
Well the picture doesn't tell us if you correctly identified the pot's wiper terminal to wire to the analog input pin. You should take a multimeter voltage reading from ground to the input pin to see if the voltage does change from 0 to +5vdc as you move the pot's know through its range. Also 110K ohm pot is awful large value, analog input pins work best with 10k ohm or less of source impedance.
Lefty
I correctly identified the pot's outputs, because i tested it on the arduino uno today , and it worked perfectly, the same code, all works fine with uno but not with this mega 2560. I can only tell you how I would approch troubleshooting this symptom. I would first take a meter and measure the actual voltage applied to the pin and see if it tracks with turning of the pot. That would give me a good indication to next look at wiring or the sketch code. If you don't own a meter you should get one soon, as anyone building even simple projects using an arduino should. Lefty While the pot was connected(it was connected right) to the arduino , i used a meter to measure the voltage in the pot, while i changed the resistance value, but the output of the pot was at 5 v all the time...
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19380
I don't think you connected the grounds, Dave.
|
 |
« Reply #9 on: October 02, 2012, 02:42:54 pm » |
And when you disconnected the wiper from the input, and measured the voltage on the wiper..? And when you tried a different input..?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #10 on: October 02, 2012, 03:04:40 pm » |
Well the picture doesn't tell us if you correctly identified the pot's wiper terminal to wire to the analog input pin. You should take a multimeter voltage reading from ground to the input pin to see if the voltage does change from 0 to +5vdc as you move the pot's know through its range. Also 110K ohm pot is awful large value, analog input pins work best with 10k ohm or less of source impedance.
Lefty
I correctly identified the pot's outputs, because i tested it on the arduino uno today , and it worked perfectly, the same code, all works fine with uno but not with this mega 2560. I can only tell you how I would approch troubleshooting this symptom. I would first take a meter and measure the actual voltage applied to the pin and see if it tracks with turning of the pot. That would give me a good indication to next look at wiring or the sketch code. If you don't own a meter you should get one soon, as anyone building even simple projects using an arduino should. Lefty While the pot was connected(it was connected right) to the arduino , i used a meter to measure the voltage in the pot, while i changed the resistance value, but the output of the pot was at 5 v all the time... Sounds like the ground end of the pot isn't connected correctly to arduino ground, or bad wire connection, bad pot terminal, or something of that manner. If you measure only +5vdc on the pin then your software will only read values of 1023.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 17
|
 |
« Reply #11 on: October 03, 2012, 01:08:26 pm » |
Well the picture doesn't tell us if you correctly identified the pot's wiper terminal to wire to the analog input pin. You should take a multimeter voltage reading from ground to the input pin to see if the voltage does change from 0 to +5vdc as you move the pot's know through its range. Also 110K ohm pot is awful large value, analog input pins work best with 10k ohm or less of source impedance.
Lefty
I correctly identified the pot's outputs, because i tested it on the arduino uno today , and it worked perfectly, the same code, all works fine with uno but not with this mega 2560. I can only tell you how I would approch troubleshooting this symptom. I would first take a meter and measure the actual voltage applied to the pin and see if it tracks with turning of the pot. That would give me a good indication to next look at wiring or the sketch code. If you don't own a meter you should get one soon, as anyone building even simple projects using an arduino should. Lefty While the pot was connected(it was connected right) to the arduino , i used a meter to measure the voltage in the pot, while i changed the resistance value, but the output of the pot was at 5 v all the time... Sounds like the ground end of the pot isn't connected correctly to arduino ground, or bad wire connection, bad pot terminal, or something of that manner. If you measure only +5vdc on the pin then your software will only read values of 1023. The pot is fine , i tested it on UNO, works perfectly. I connected the Pot terminals even at solder in the back of the board. NONE of the analog ports is working,but the DIGITAL are okay.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 283
Posts: 15443
Measurement changes behavior
|
 |
« Reply #12 on: October 03, 2012, 01:15:11 pm » |
The pot is fine , i tested it on UNO, works perfectly. I connected the Pot terminals even at solder in the back of the board. NONE of the analog ports is working,but the DIGITAL are okay. While the pot was connected(it was connected right) to the arduino , i used a meter to measure the voltage in the pot, while i changed the resistance value, but the output of the pot was at 5 v all the time... Well you are going to have to figure out why you only measure +5vdc at the pot's wiper pin output wired to the analog input pin, even when you turn the knob through it's range. The fact that you only see +5vdc applied to the analog input pin needs to be fixed before you can expect the 2560 board to read the pots value. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 76
Posts: 6852
Arduino rocks
|
 |
« Reply #13 on: October 03, 2012, 05:10:00 pm » |
Have you tried replacing int sensorValue = analogRead(A0);
with int sensorValue = analogRead(0);
I don't have a Mega to hand to test what A0 compiles to (its definitely done different in Arduino 1.0 from earlier Arduino softwares - I can't find the definitions in 1.0). Perhaps its broken for Megas? Sounds a bit unlikely though.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 57
|
 |
« Reply #14 on: October 03, 2012, 05:31:18 pm » |
It sounds like your pot is hooked up wrong or something electrical is wrong with the Mega since you said the Uno works.
Did you try running the A0 pin straight to ground? Just to see if the Mega will report back 0? If that works take the wire out of A0 completely and see what the results are. 'Normally' you get fluctuating values. If it comes back as 1023 there is a problem.
|
|
|
|
|
Logged
|
|
|
|
|
|