Go Down

Topic: Compiler error message (Read 1 time) previous topic - next topic



I have Arduino 0021 installed and I get the following messages when I try to load the code (see below).  This something missing on my system?

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
   at processing.app.Sketch.setCurrentCode(Unknown Source)
   at processing.app.Sketch.load(Unknown Source)
   at processing.app.Sketch.<init>(Unknown Source)
   at processing.app.Editor.handleOpenInternal(Unknown Source)
   at processing.app.Editor.<init>(Unknown Source)
   at processing.app.Base.handleOpen(Unknown Source)
   at processing.app.Base.handleOpen(Unknown Source)
   at processing.app.Base.handleOpenPrompt(Unknown Source)
   at processing.app.Editor$5.actionPerformed(Unknown Source)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
   at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
   at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
   at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1225)
   at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1266)
   at java.awt.Component.processMouseEvent(Component.java:6263)
   at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
   at java.awt.Component.processEvent(Component.java:6028)
   at java.awt.Container.processEvent(Container.java:2041)
   at java.awt.Component.dispatchEventImpl(Component.java:4630)
   at java.awt.Container.dispatchEventImpl(Container.java:2099)
   at java.awt.Component.dispatchEvent(Component.java:4460)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
   at java.awt.Container.dispatchEventImpl(Container.java:2085)
   at java.awt.Component.dispatchEvent(Component.java:4460)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Code from Gravitech.

Example program I2C-16IO interface with Arduino.

SETUP:    I2C-16IO => Arduino
          PIN11 => ground, PIN20 => A5, PIN21 => A4, PIN22 => +5V
Note:     The program is written for address 0x40 (Arduino address 0x20).
          This program was tested using Arduino Nano
Document: PCA9535 datasheet
Updated:  September 4, 2008
E-mail:   support@gravitech.us
(C) Copyright 2008 All Rights Reserved

#include <Wire.h>

void setup()
  Wire.begin();             // join i2c bus (address optional for master)

                      Main Loop
void loop()
  const int I2C_address = 0x20;  // I2C write address
  byte  Data_In;            // Input data
  byte  Data_Out;           // Output data
  Data_Out = 0x55;          // Intialize output data
  Wire.send(6);             // Configure PORT 0 and PORT 1
  Wire.send(0xFF);          // P0.7 6 5 4 3 2 1 0
  Wire.send(0x00);          //   I  I I I I I I I
  Wire.endTransmission();   // P1.7 6 5 4 3 2 1 0
                            //   O  O O O O O O O
  Wire.send(3);             // Set output port to %01010101

    delay (1000);
    Data_Out = Data_Out ^ 0xFF; // Invert all of the bits
    Wire.send(3);                // Set output port to %10101010
    Wire.send(0);                // Set the pointer to REGISTER0
    Wire.requestFrom(I2C_address, 1);
    while(Wire.available())      // Checkf for data from slave
      Data_In = Wire.receive();  // receive a byte as character
    //Display status of PORT0
    Serial.print("PORT0 = ");
    Serial.println(Data_In, HEX);


Coding Badly

Are you able to compile an empty Sketch...

Code: [Select]
void setup( void )

void loop( void )


Yes, all of the examples work and some simple code I created.  It's any of the code posted on Gravateck website.   http://www.gravitech.us  I am sure it worked in an older copy of Arduino.  Does 0021 require any additional downloads?

Coding Badly

The Gravitech code compiles here.

Do you have the correct board selected?

Try upgrading to the Arduino IDE version 0022.


I have tried several boards, all did the same thing.  I will get version 0022 Now.



No Go,

I installed V 0022 and I still get the same messages as soon as I try to load the code. 

There must be something missing on this PC.    :(

Coding Badly

One more suggestions... Try to copy-and-paste the code from the forum into a new Sketch and then Verify.

If you do find something that works, please report back.


Maybe it's a problem with the sketch file name.  Does it have any spaces or special characters in it?



I did copy/paste and that works.  Here is what I found.

On my PC (running XP) if the Sketch file name has a - I get the error message.  If I replace the dash with a underscore it works!   I was using is I2C-RTC-Arduino.pde  If I change it to I2C_RTC_Arduino.pde it works OK.

Thanks for all your help.

Go Up