Go Down

Topic: 0021 code examples that won't compile. (Read 1 time) previous topic - next topic

tankslappa

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.
I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

Grumpy_Mike

Quote
firstSensor = analogRead(A0)/4;

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

tankslappa

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.
I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

mellis

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.

tankslappa

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

Anything I can do to diagnose the problem?
I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

mellis

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.

tankslappa

#6
Oct 18, 2010, 11:25 am Last Edit: Oct 18, 2010, 11:26 am by tankslappa Reason: 1
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.
I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

Go Up