Go Down

Topic: Analog inputs are averaging? (Read 998 times) previous topic - next topic

rmaurer

So, I have two analog inputs, on separate circuits, one should read 10 and the other 34, but they are both coming up as 22? 

Code:
int loadcell;
int battery;

void setup()
{
Serial.begin(9600);
}

void loop()
{
loadcell = analogRead(0);
battery = analogRead(1);
Serial.print(loadcell);
Serial.print(" ");
Serial.println(battery);
delay(100);
}

????? Help ???

Thanks, Ryan

LarryD

The way you have it in your schematic isn't the same as how you have it wired up!

retrolefty

Wiring schematic would be helpful. But take a digital multimeter and measure the voltages at analog pins 0 and 1 and see what readings you get at that point independent of your program.

Lefty


rmaurer

Checked with a multimeter, voltages are what they should be.  I dont know why the Serial monitor is showing them as averaged...  The diagram is real complex, not sure how I'd post it.  It has three batteries, a load cell, amplifier, and LEDs.  But the battery and loadcell are on totally different circuits.

retrolefty


Checked with a multimeter, voltages are what they should be.  I dont know why the Serial monitor is showing them as averaged...  The diagram is real complex, not sure how I'd post it.  It has three batteries, a load cell, amplifier, and LEDs.  But the battery and loadcell are on totally different circuits.


Well the output impedance of the signals (if too high) you are reading could be a factor, and if not that then your sketch is mangling the values before sending them out to the serial monitor.
So without wiring diagram and sketch code help will be just guessing.

Lefty

robtillaart

Quote
????? Help ???

help!!

Analogports are A0 iso 0 and A1 iso 1

give this a try. Be aware that analog reads fluctuate ...
Code: [Select]

int loadcell;
int battery;

void setup()
{
 Serial.begin(9600);
}

void loop()
{
 loadcell = analogRead(A0);
 battery = analogRead(A1);
 Serial.print(loadcell);
 Serial.print(" ");
 Serial.println(battery);
 delay(100);
}
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Grumpy_Mike

Try this:-
Code: [Select]
void loop()
{
loadcell = analogRead(0);
loadcell = analogRead(0);
battery = analogRead(1);
battery = analogRead(1);
Serial.print(loadcell);
Serial.print(" ");
Serial.println(battery);
delay(100);
}

It will help if the impedance of each input is too high.

Go Up