Ardino CW Beacon Programming Problem

I'm trying to build a Cw beacon using an Arduino UNO. I used an existing program used for a Balloon Beacon. I copied the .txt file and saved it as a .pde file. When I try to open the file wile running Arduino Sketch 0022, I get a multitude of Java errors and a blank screen.

Here's the program http://hiwaay.net/~bbrown/keyedcwcode.txt

Any help would be appreciated.

TNX Gary, KF9CM

When I try to open the file wile running Arduino Sketch 0022, I get a multitude of Java errors and a blank screen.

What errors?

Are you able to open other sketches?

Exception in thread "ANT-EventQueue-0" java.lang.ArrayIxt BoundsException: 0

is one of the errors plus about 25 more.

I wish there was a way to copy all the red error messages.

I can run all other programs, blink,etc

TNX Gary

I started the IDE, pasted the text copied from your link, and got just one error message.

sketch_oct10a:16: error: 'int tone' redeclared as different kind of symbol
C:\Users\pjs9486\Documents\arduino-0022\hardware\arduino\cores\arduino/WProgram.h:24: error: previous declaration of 'void tone(uint8_t, unsigned int, long unsigned int)'

When I deleted this line, since tone is never referenced, the code compiles just fine.

I wish there was a way to copy all the red error messages.

Drag the mouse across them, to highlight them, then use Ctrl-C to copy them.

Thanks for that tip Paul. Here it is (maybe 33 errors)

Exception in thread “AWT-EventQueue-0” java.lang.ArrayIndexOutOfBoundsException: 0
at processing.app.Sketch.setCurrentCode(Sketch.java:1106)
at processing.app.Sketch.load(Sketch.java:218)
at processing.app.Sketch.(Sketch.java:140)
at processing.app.Editor.handleOpenInternal(Editor.java:2114)
at processing.app.Editor.(Editor.java:308)
at processing.app.Base.handleOpen(Base.java:699)
at processing.app.Base.handleOpen(Base.java:664)
at processing.app.Base.handleOpenPrompt(Base.java:653)
at processing.app.Editor$5.actionPerformed(Editor.java:500)
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)

Here it is (maybe 33 errors)

No that is just one error, the other lines are pointing in more detail at where the error is.

Are you sure that is in the Arduino?

It's in the Arduino Sketch 0022 program. I can load and run all other programs in the Arduino Sketch 0022 program, not this one.

Well I don’t know what you are doing wrong because I can compile it without errors, try a cut an paste on this:-

//**************************************************
// Morse Code Balloon Beacon
// by Bill Brown WB8ELK <http://www.wb8elk.com>
// 
// Transmits Morse Code for balloon tracking
// by keying the SparkFun 434 MHz transmitter module
//
// Created 29 December 2008
// << -- Keyed CW mode -- >>
//**************************************************

int adc0;
int adclen;
byte morse;
byte cwlen;
byte cw;
int tone;
byte x;

int cwoutPin = 9; // TX output pin

char asciibuf[5];
char callsign[15] = {'W','B','8','E','L','K',' ','B','A','L','L','O','O','N'};


// ********************************************************
// ASCII to Morse Code Lookup Table
// ********************************************************

const unsigned char morse_table[63] = { 	// Morse Code Lookup table

	0b00000001,	//;sp - 0x20 
	0b01001010,	//; ! - 0x21
	0b01101101,	//; " - 0x22
	0b01011110,	//; # - 0x23 // Not available in Morse Code - replace with "-"
	0b10110111,	//; $ - 0x24
	0b01011110,	//; % - 0x25 // Not available in Morse Code - replace with "-"
	0b00111101,	//; & - 0x26
	0b01100001,	//; ' - 0x27
	0b00110010,	//; ( - 0x28
	0b01010010,	//; ) - 0x29
	0b01011110,	//; * - 0x2A // Not available in Morse Code - replace with "-"
	0b00110101,	//; + - 0x2B 
	0b01001100,     //; , - 0x2C
	0b01011110,     //; - - 0x2D
	0b01010101,     //; . - 0x2E
	0b00110110,	//; / - 0x2F
	0b00100000,	//; 0 - 0x30
	0b00100001,	//; 1 - 0x31
	0b00100011,	//; 2 - 0x32
	0b00100111,	//; 3 - 0x33
	0b00101111,	//; 4 - 0x34
	0b00111111,	//; 5 - 0x35
	0b00111110,	//; 6 - 0x36
	0b00111100,	//; 7 - 0x37
	0b00111000,	//; 8 - 0x38
	0b00110000,	//; 9 - 0x39
	0b01111000,	//; : - 0x3A
	0b00101010,	//; ; - 0x3B
	0b00110010,	//; < - 0x3C // send ( since no < in Morse
	0b00101110,	//; = - 0x3D 
	0b01010010,	//; > - 0x3E // send ) since no > in Morse
	0b01110011,	//; ? - 0x3F
	0b01101001,	//; @ - 0x40 
	0b00000101,	//; A - 0x41
	0b00011110,	//; B - 0x42
	0b00011010,	//; C - 0x43
	0b00001110,	//; D - 0x44
	0b00000011,	//; E - 0x45
	0b00011011,	//; F - 0x46
	0b00001100,	//; G - 0x47
	0b00011111,	//; H - 0x48
	0b00000111,	//; I - 0x49
	0b00010001,	//; J - 0x4A
	0b00001010,	//; K - 0x4B
	0b00011101,	//; L - 0x4C
	0b00000100,	//; M - 0x4D
	0b00000110,	//; N - 0x4E
	0b00001000,	//; O - 0x4F
	0b00011001,	//; P - 0x50
	0b00010100,	//; Q - 0x51
	0b00001101,	//; R - 0x52
	0b00001111,	//; S - 0x53
	0b00000010,	//; T - 0x54
	0b00001011,	//; U - 0x55
	0b00010111,	//; V - 0x56
	0b00001001,	//; W - 0x57
	0b00010110,	//; X - 0x58
	0b00010010,	//; Y - 0x59
	0b00011100	//; Z - 0x5A
	
};

// END of Morse Table

void setup()
{

  pinMode(cwoutPin, OUTPUT);      // sets the digital pin as output 

}


void loop()
{
  
// Morse Code repeating sequence main loop

while(1){

// ***********************
// Send Callsign
// ***********************



delay(10000); // Wait 10 seconds between each transmission


for(x=0;x<14;x++){
	sendcw(callsign[x]);
  }

delay(1000); // Wait 1 second before sending telemetry

//***************************************************
// Read the Temperature Sensor and send the value out  
//***************************************************

 adc0 = analogRead(0);
 
 itoa(adc0, asciibuf, 10);
 
  if (adc0<10){
    adclen = 1;
  }
  if (adc0<100 && adc0>=10){
    adclen = 2;
  }
  if (adc0<1000 && adc0>=100){
    adclen = 3; 
  }
  if(adc0>=1000){
    adclen = 4;
  }

  for (cw=0;cw<adclen;cw++){
    sendcw(asciibuf[cw]);
    delay(100);
  }

  
} // End of main while
  
  
} // End of Loop

//------------------------------------------------

// ***********************
// Functions
// ***********************

//*********************
// CW output function *
//*********************
void sendcw(int cwchar)
{
  
 morse = morse_table[cwchar-0x20];
  
while(1){

    if(cwchar == ' '){ // if SPACE character then delay 500 mSec between words
      delay(500);
      return;
    }
  
    if (morse & 0b00000001){ // compare LSB [ 1=Dit  0=Dah ]
      digitalWrite(cwoutPin, HIGH);
      delay(100); // dit timing - 100 msec
      digitalWrite(cwoutPin, LOW);
      delay(100);    
    }
    else{     
      digitalWrite(cwoutPin, HIGH);
      delay(300); // dah timing - 300 msec
      digitalWrite(cwoutPin, LOW);
      delay(100);       
    }

    morse = morse >> 1; // shift right to see if Dit or Dah

    if(morse == 1){ // if the value is 1 then end of CW character
      delay(200);
      return;
    }
  } // End of Morse while loop
  
} // End of SENDCW routine
// -------------------------------

Nope still does the same thing. Maybe I've got a corrupt Java program?

Yes it looks like it. Try a reinstall. By the way you don't need that while(1) outer most loop because loop() does what it says on the tin and constantly repeats.

Thanks Mike,

I uninstalled Java ver 6 and reinstalled a fresh version off of their site, rebooted and I still have the same thing

I think you need to start a new thread in installation and troubleshooting and give detailed of your OS and what you get and see if anyone has come across this problem. At a guess I would say you had a corrupt file that is not being wiped on install or an OS that is not quite compatible. It might be worth hacking at that sketch till you get the smallest sketch that actually shows the problem.

Buzz239:
It’s in the Arduino Sketch 0022 program. I can load and run all other programs in the Arduino Sketch 0022 program, not this one.

at processing.app.Sketch.setCurrentCode(Sketch.java:1106)
at processing.app.Sketch.load(Sketch.java:218)
at processing.app.Sketch.(Sketch.java:140)
at processing.app.Editor.handleOpenInternal(Editor.java:2114)
at processing.app.Editor.(Editor.java:308)

I’m going to take a wild guess at the problem and say that you are not running the Arduino IDE but its cousin Processing.

I did ask that question in reply #5 and he did say it was the arduino 0022. However Arduino does share a lot of the processing files, but I think it is the underlying Java

I found out the problem. Sorry I was told to go over to the programming section and forgot about this thread. Apparently when I saved the code with "Morse code.pde" I got Java errors. When I saved it with just " Morse.pde", it took with no Java errors. Java doesn't like spaces between words when saving. Go figure

TNX Guys