0021 code examples that won't compile.

Hi,

Just a quick heads up. Two examples, SerialCallResponseASCII.pde and SerialCallResponse.pde refer to Analogue 0 as A0 in the examples, so won't compile.

The line in both is: firstSensor = analogRead(A0)/4;

This needs changing to firstSensor = analogRead(0)/4;

Curiously both the examples then have the second analogue port referred to correctly only a couple of lines later.

firstSensor = analogRead(A0)/4;

This line compiles on my version 21 environment? They have defined A0 as a constant.

That's curious... They won't compile on my 0021 in windows. A0 is unknown. Where are they defined?

If nothing else, the references should at least be consistent between the two statements. Either use the A0/A1 constants for both, or the purely numeric reference.

They're defined in WProgram.h, an #include for which should be automatically inserted into the sketch in the pre-processing done as part of the build process.

Well they're certainly in my WProgram.h, I wonder why it won't compile :-/

Anything I can do to diagnose the problem?

What's selected in the Tools > Board menu? Trying holding down shift as you click the play button in the toolbar, and post the output here.

Ahhhh, got it!

I've been playing about with the Optiboot bootloader, so I have a whole section at the top of my board list for [optiboot] loaded boards... The example compiles fine if I say the destination is a regular ATmega328, but not if I select the [optiboot]ATmega328.

A bit of digging reveals the problem. The libraries they have included for the Optiboot bits are from 0018... And 0018 didn't have those constants. I shall fix the Optiboot libraries on my machine.

It still might be worth changing the second analogue port references to use the constant, just so they are consistent.

Thanks for the assist.