Noob compiling problem

I’ve been testing the example sketches for the FEZ Medusa, can get LEDStrip to compile, but not the Joystick sketch.

I noticed one difference between the two: LEDStrip declares pins earlier and has void setup() empty:

FEZMedusa board;
LEDStrip led(10);
LEDStrip led1(1);

void setup() {

}

while Joystick declares them in void setup():

FEZMedusa board;
CharDisplay* display;
Joystick* joystick;

void setup() {
display = new CharDisplay(1);
joystick = new Joystick(3);
}

SO: ==> Which is the correct way of doing this, and any reason why Joystick won’t run? I get the following errors:

‘delay’ was not declared in this scope
error: ‘byte’ does not name a type
Joystick.ino: In function ‘void loop()’:
Joystick:47: error: ‘delay’ was not declared in this scope

Here’s the full Joystick code:

#include <Gadgeteering.h>
 #include <FEZMedusa.h>
 #include <SPI.h>
 #include <IO60P16.h>
 #include <CharDisplay.h>
 #include <Joystick.h>

using namespace GHI;
using namespace GHI::Interfaces;
using namespace GHI::Modules;
using namespace GHI::Mainboards;

FEZMedusa board;
CharDisplay* display;
Joystick* joystick;

void setup() {
  display = new CharDisplay(1);
  joystick = new Joystick(3);
}

void loop() {
  int xVal = (int)(joystick->getX() * 10.0);
  int yVal = (int)(joystick->getY() * 10.0);
    
  display->clear();
  display->print((char)xVal + 48);
  display->print((char)yVal + 48);
  display->print(joystick->isPressed() ? "P" : "N");
  
  delay(500);
}

Welcome to the Forum.

Please post your Compiler Errors (from outpunt window)
and please use the code tag (101010 button above Forum Editor)

Edit: now I saw the Compiler Errors. Would have been easier to see with code tags :wink:

Include “arduino.h” as the first line as well.

@ spongefile - I have actually just tried your example as is and it compiled for me correctly:

#include <Gadgeteering.h>
 #include <FEZMedusa.h>
 #include <SPI.h>
 #include <IO60P16.h>
 #include <CharDisplay.h>
 #include <Joystick.h>

using namespace GHI;
using namespace GHI::Interfaces;
using namespace GHI::Modules;
using namespace GHI::Mainboards;

FEZMedusa board;
CharDisplay* display;
Joystick* joystick;

void setup() {
display = new CharDisplay(1);
joystick = new Joystick(3);
}

void loop() {
int xVal = (int)(joystick->getX() * 10.0);
int yVal = (int)(joystick->getY() * 10.0);

display->clear();
display->print((char)xVal + 48);
display->print((char)yVal + 48);
display->print(joystick->isPressed() ? "P" : "N");

delay(500);
}

Are you sure your Arduino IDE is setup correctly, what version are you using? Can you compile default sketch?

Well, this is strange. Suddenly can’t compile Blink for Arduino either. Clearly a problem with the IDE, now I just have to find out WHAT that problem is. Using 1.0.5 on OSX.

Blink errors, in case anyone has bright ideas:

Blink.ino:10:21: error: Arduino.h: No such file or directory
Blink.ino: In function ‘void setup()’:
Blink:15: error: ‘OUTPUT’ was not declared in this scope
Blink:15: error: ‘pinMode’ was not declared in this scope
Blink.ino: In function ‘void loop()’:
Blink:20: error: ‘HIGH’ was not declared in this scope
Blink:20: error: ‘digitalWrite’ was not declared in this scope
Blink:21: error: ‘delay’ was not declared in this scope
Blink:22: error: ‘LOW’ was not declared in this scope

Have you tried to reinstall the IDE?

I’m not sure if this has anything to do with it, but we noticed a bug on Linux, so it may be shared with other unix-like environments. When using the 64bit 1.5.4 package for the arduino IDE the compilers for some of the boards were still 32bit. This was not documented and resulted in a simple “command not found” style of error. After some digging, Jeff discovered they were 32bit binaries and worked once the lib32 packages were installed.

Looks like something related to missing files or files in the wrong location. Starting from scratch now.

Found the problem, I was trying to follow this instruction on a Mac:

Copy or move the file boards.txt from the Arduino\Hardware folder to C:\Program Files (x86)\Arduino\hardware\arduino.

Couldn’t find a Program Files folder, so I made a new folder under Arduino called hardware, and another one under that called arduino, and put boards.txt in there. Clearly not correct.

What’s the correct place/method on a Mac?

I think this fixed it:

  1. Made a new folder under Arduino called hardware.
  2. Made a new folder under that called BetaMedusa.
  3. put boards.txt, bootloaders and programmers.txt in there.

Ok nope. Blink compiles fine.
Then I try Joystick, get the same old “delay not in scope” error.
Then I try Blink again and now that no longer works.

Closing in on something but not sure what.

MAC USERS:

I found the following helpful (replace Hexbright with FEZMedusa):

http://community.hexbright.com/Wiki/Intro_to_Programming

Go to your Documents (~/Documents) folder and open the Arduino directory (create it if it doesn’t exist). Create another folder within there called hardware and then one more within that called hexbright. Drop boards.txt in there. You can also download the hardware folder from the samples within the GitHub project and put it directly in the Arduino directory, as shown in the screenshot.

For the current version or Arduino on Mac OS X 10.8.x you will need to right click on Arduino.app

in the applications folder and choose “Show Package Contents” from there navigate to: /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt

Open the boards.txt file from the file path as well as the one you downloaded. Copy the contents of the downloaded one to the top of the file in Arduino.app. Save the file and reopen Arduino.app. From there you can Navigate to Tools > Board > HexBright.

@ spongefile - Glad you found a solution!! Good job! Some steps I suggest you use:

[ol]for the [em]boards.txt[/em] that comes with GHI’s package and/or gitbucket, edit it and remove all text from the file other than the the lines that start with "medusa."
create this path if it doesn’t exist: ~[em]/Documents/Arduino/hardware/GHI/[/em]
Install edited GHI [em]boards.txt[/em] (from step 1) into ~[em]/Documents/Arduino/hardware/GHI/[/em]
leave the original[em] boards.txt[/em] (from the Arduino package) where it was installed.[/ol]

Benefit of this is that anytime you download a new Arduino environment you’ll get all their changes, and any time you get a new [em]boards.txt[/em] from GHIElectronics, there will never be a conflict and you’ll have the latest from both companies.

P.S. We’ll be changing our installation and/or instructions to reflect this.

It seems that if I call the folder GHI it doesn’t work. If I call it FEZ Medusa, it does.

Also, there was stuff missing from the boards.txt file, since I added that I’m past this problem and on to a new one :slight_smile:

https://www.ghielectronics.com/community/forum/topic?id=14045