Arduino Mega: Sensor Range Help

Hey Guys-

I'm doing a group project with the Arduino Mega, and we're all a little new to the whole Arduino thing. We've been testing our circuits on a Duemilanove, and everything was working great. Nothing too complicated, just a couple of flex sensors hooked up to analog 1 and 2. We had a great range of data- over 100 points between the min and max, far more than we need.

However, when we rigged this up to the Arduino Mega, our data range went from over 100 to only 1! The sensor is still responsive. We don't know why this is happening. Is the Mega different from the Duemilanove in any major ways that would cause this problem?

Here is our code for reference, though we don't think that's the problem.

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

void loop() { int analogValue1 = analogRead(1); int analogValue2 = analogRead(2);

Serial.print("Val1: "); Serial.println(analogValue1); Serial.print("Val2: "); Serial.println(analogValue2); delay(100); }

Is there something wrong with analogue input zero?

No, our Prof advised us to not use analog input 0, but we can give it a shot.

Same result with pin 0, which makes sense. Still needing help.

What else have you tried to determine if your analogue inputs work?

What has your prof got against input zero?

We've been using different sensors, and trying the code on other boards to try and troubleshoot.

I don't know what else to try to see if the analog inputs work. We're all pretty new to this.

And no idea what he has against analog 0. ::shrug::

Is there a diagnostic test we can run?

That you have a prof suggests you’re students - what would be a sensible simple way of testing an analogue input?

We don't even know... we didn't think we could get simpler than a sensor and a resistor. We've tested all the inputs of the Mega, getting different results on each one.

Yes, you should test the analog inputs pins independently from your sensor and sensor wiring. That can be as simple as jumpering +5vdc to your analog input pin 1 and connecting ground to analog input pin 2 and then run your posted program.
The results of that test will tell you which direction you need to go next. Will take 1 min to test and then give us the results. If the results of the test are good then you will have to somehow provide us with wiring details and sensor information to help any further. If the test results are bad then trying a different mega board with the same test would be called for.

Lefty