unexpected token: def

edited March 2014 in Arduino

Hi all,

I'm newbie here and I'm confused because I've followed all steps to have processing / arduino running here, but still I'm getting unexpected errors.

The top of the code:

// Maurice Ribble 
// 6-28-2009
// http://www.glacialwanderer.com/hobbyrobotics

#define AI0 0
#define AI1 1
#define AI2 2
#define AI3 3
#define AI4 4
#define AI5 5

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

ERROR: unexpected token: def on line 5 #define AI0 0

I've installed the Android Mode but it seems not to recognize the arduino syntax.

Any help would be appreciated.

Thanks.

Tagged:

Answers

  • edited March 2014

    I've installed the Android Mode but it seems not to recognize the Arduino syntax.

    Android Mode uses a Java-like syntax too. Arduino uses a C-like syntax instead! b-(

  • You cannot use #define in processing as GoToLoop said processing is based on top of java. If you want to use processing with arduino check the serial examples http://www.processing.org/reference/libraries/serial/.

  • if these are simple constants you can replace them with

    public static Integer AI0 = 0;

    (replace Integer with the required type)

  • edited March 2014

    For Java-equivalent for #define performance-wise, we gotta use final for primitive & String! :-B
    And while we're at it, slap a static as well! :)>-

    static final int AI0 = 0, AI1 = 1, AI2 = 2;  // etc...
    
  • mmm I guess i got crazy, I setup the Android mode in Processing, thinking on Arduino mode XD

    thanks ;)

Sign In or Register to comment.