Hi everyone,
I have problem in analog inputs that if i apply any voltage value between 0---5 v to the arduino in Proteus it works as a digital input only(high or low)
i don't Know is the problem in analog to digital converter or what
to the arduino in Proteus
In what?
Proteus that's the program to simulate circuits
So, why aren't you asking your question on the Proteus forum?
Ok, thank you.
Hi,
I have problem with analog input pins too. i am pretty new with arduino,
have more experience programming in Basic language,
made some good working projects with Atmegas 32 and 8
I have chinesse Arduino Mega clone with Atmega 2560 ic.
In my project i need at least 12 analog inputs, but half of them not workint properly.
i am reading analog pins and sending data to serial.
my code example:
int sensorPin0 = A0;
int sensorPin1 = A1;
.................
int sensorPin15 = A15;
int Value = 0; (tried to write int Value0 = 0, int Value1 = 0, ........int Value15 = 0, no difference)
void setup() {
Serial.begin(9600);
pinMode(sensorPin0, INPUT); (no difference with or without these lines, just tried)
..............................
pinMode(sensorPin15, INPUT);
}
void loop() {
analogRead(sensorPin0);
delay(300);
Value = analogRead(sensorPin0);
Serial.print("A0 = ");
Serial.print(Value);
Serial.println("\r");
delay(300);
analogRead(sensorPin1);
delay(300);
Value = analogRead(sensorPin1);
Serial.print("A1 = ");
Serial.print(Value);
Serial.println("\r");
delay(300);
...................................................
analogRead(sensorPin15);
delay(300);
Value = analogRead(sensorPin15);
Serial.print("A15 = ");
Serial.print(Value);
Serial.println("\r");
delay(300);
(tried 1000ms delay time between analog readings,
tried to make only 1 reading per pin at first, but no difference)
So, when i connect all analog pins to GND through 10K (or 5K or 2K, no difference)
i get 0 in all ADC pins, then i connect +5v to pin A0 in Serial monitor i get:
1023 in pins A0, A5, A7, A9, A11, A13 and A15 at same time.
when i connect +5v to pins A5, A7, A9, A11, A13 or A15, i get 0 anyway,not 1023
(these pin not reacting at all)
i have tried other way, i connect all analog pins to +5v through 10K (or 5K or 2K, no difference)
all pins show 1023 as they should, then connecting GND to pin A0 i get 0 (thats OK),
but when i connect GND to A9 i get 0 in pins A9 and A5, A7, A11, A13, A15 at same time (these pins do not react to GND).
pins A1, A2, A3, A4, A6, A8, A10, A12, A14, works as it should
getting flouting readings from all pins when they are not connected anywhere.
All analog pins works fine if i use them as DIGITAL OUTPUTS, (did not tried as digital inputs)
they do not short to each other (multimeter shows 48 to 53 Kohms)
or to GND (multimeter shows 24 to 25 Kohms)
or to +5v (multimeter shows 23 to 24 Kohms)
AREF pin to +5v = 22 Kohms.
AREF pin to GND = 23 Kohms
Tried to reburn bootloader, and so on, nothing helps, faulty IC i think.
anyone has any ideas whats going on here?
Thanks
I have chinesse Arduino Mega clone
Have you considered contacting the vendor?
no, i bought it maybe 1 year ago, tested maybe blink sketch, maybe serial and thought that every thing will work, had no problems with any atmega from ebay. Now i tried to use it, and it is as it is.
i should get new mega board in few days i hope, maybe this one will be better
Hi again,
today i tried same code with my UNO board (china also), and getting very similar result,
pin A5 reading no reaction at all to A5 input change, but reading changes when other inputs ger resistence change.
dont think both ICs are faulty, reinstaled arduino software 1.6.9 to 1.8.1 but nothing changed, problem is something other, but where?
I am experience this same issues A0 - A7 work fine but A8 - A15 nothing. Did you ever find the answer?
hi, have not been here for a long time, but maybe this post will help someone in future.
I ordered new original mega board from ebay, i received it after maybe 1 month or more, tested same code and got same result, so problem was my code itself not boards or ICs.
i have changed code from this:
analogRead(sensorPin0);
delay(300);
Value = analogRead(sensorPin0);
Serial.print("A0 = ");
Serial.print(Value);
Serial.println("\r");
delay(300);
to this:
Value = analogRead(sensorPin0);
Serial.print("A0 = ");
Serial.println(Value);
Value = 0;
delay(2);
if i remember it wright, it started to work after i removed line " Serial.println("\r"); " and worked even beter when i added line " Value = 0; ".
Whenever you get this sort of problem IMO it's best to go back to the examples provided with the IDE. In the Analog example you could have then changed the pin used one at a time to check the board out .
You know the examples will work and that identifies the source of the problem .