Pages: [1]   Go Down
Author Topic: 0021 code examples that won't compile.  (Read 1072 times)
0 Members and 1 Guest are viewing this topic.
London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 34602
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
firstSensor = analogRead(A0)/4;
This line compiles on my version 21 environment?
They have defined A0 as a constant.
Logged

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Anything I can do to diagnose the problem?
Logged

I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 18, 2010, 04:26:23 am by tankslappa » Logged

I was born with a soldering iron in my hand. If you look very closely you can still see the scar.

Pages: [1]   Go Up
Jump to: