Unknown Error Messages

I'm running a code that allows for a range-activated system that when an object is detected in a certain range, it will fire two Lego missile launchers. Just a toy demonstrating basic automation, artificial intelligence, and coding for a project.

Basically, a potentiometer is used to select what modes I want to use: Rest, Stationary, Rotate, and an empty state, which I may use for Bluetooth... Once this is sorted out.

My knowledge of the actual workings of the programming software and java are extremely limited. So any help will be appreciated:

Exception in thread "Thread-5" java.lang.StackOverflowError
    at java.util.regex.Pattern$Loop.match(Pattern.java:4275)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
    at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
    at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
    at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
    at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4078)
    at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
    at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
    at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)

I repeats like this several dozen or hundred times... The actual error window exceeds the maximum character allowance of the post.

I will include the actual code momentarily...

Looks like you crashed the Arduino IDE!

Can't wait to see your code.

#include <Servo.h>
Servo servo1;
Servo servo2;
int led1Pin = 2; 
int led2Pin = 3;
int led3Pin = 4;
int led4Pin = 5;
int trigPin = 30;
int echoPin = 32;
int ledPin = 13;
int analogPin = 1; 
int run;

void setup()  {
servo1.attach(9);
servo2.attach(10);
servo1.write(0);
servo2.write(90);
Serial.begin(9600);
Serial.print("RANGE-ACTIVATED MISSILE SENTRY");
Serial.println();
digitalWrite (led1Pin, LOW);
digitalWrite (led2Pin, LOW);
digitalWrite (led3Pin, LOW);
digitalWrite (led4Pin, LOW);
digitalWrite (ledPin, LOW);
run=0;
}
void loop() {
int analogState = analogRead(analogPin);
digitalWrite(ledPin,HIGH);
if((analogState<=1023)&&(analogState>750)){
  Serial.println("REST");
  Serial.println("---");
  digitalWrite (led1Pin, HIGH);
  digitalWrite (led2Pin, LOW);
  digitalWrite (led3Pin, LOW);
  digitalWrite (led4Pin, LOW);
   run=0;
   delay(5000);
   return;
   }
if((analogState<=750)&&(analogState>500)){
   Serial.print("SAP - ");
   digitalWrite (led1Pin, LOW);
   digitalWrite (led2Pin, HIGH);
   digitalWrite (led3Pin, LOW);
   digitalWrite (led4Pin, LOW);
   fireCheck();
   return;
   }
 if((analogState<=500)&&(analogState>250)){
   Serial.print("RAP - ");"
   digitalWrite (led1Pin, LOW);
   digitalWrite (led2Pin, LOW);
   digitalWrite (led3Pin, HIGH);
   digitalWrite (led4Pin, LOW);
    int position;
    for (position=0; position<180; position+=10){
     servo1.write(position);
     fireCheck(); //Every time it goes 1 degree, it will perform a search for an object in the firing range
     delay(50);
      }
    for (position=180; position>=0; position-=10){
     servo1.write(position);
     fireCheck();
     delay(50);
     run=5;    
     }
     return;  
      if(analogState<=65){
        digitalWrite (led1Pin, LOW);
        digitalWrite (led2Pin, LOW);
        digitalWrite (led3Pin, LOW);
        digitalWrite (led4Pin, HIGH);
        return;
    }
}

void fireCheck(){
  long duration, inches;
  pinMode(trigPin, OUTPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);
  inches = ((duration/73.746)/2);
  if ((inches<18)&&(run>10)){
    servo2.write(60);
    delay(100);
    servo2.write(120);
    delay(100);
    servo2.write(90);
    run = 0;
    delay(5000);
  }
  run=run+1;
  return(fireCheck());
}

Its strange… I’ve tested about half a dozen other sketches and they work perfectly… Bluetooth, VirtualWire, LCD, Servos… All work perfectly.

I apologize if I deleted any brackets or such when trimming the code for the post. If there are any miscellaneous code errors, just tell me. If you have any questions on the running, I’m glad to answer

This recursive call will certainly blow up the stack at runtime:

void fireCheck(){
.
.
.
  return(fireCheck());
}

Very helpful, but I deleted it and that still didn't fix it... I must still have problems. I will look through it and try to trim some fat and see.

   Serial.print("RAP - ");"

The extraneous quote at the end of this line will drive the IDE crazy!

You are also missing one } near the end of the loop() function.

Pete

If you press Ctrl-T and the IDE won't format your code, you have an error somewhere. Fix the format problem first, then look into the remaining issues.

el_supremo:    Serial.print("RAP - ");"

The extraneous quote at the end of this line will drive the IDE crazy!

You are also missing one } near the end of the loop() function.

Pete

Wow. Thank you so much! That fixed everything. Thank you again. Now I can see about the integration of the Bluetooth. Thanks once again.

BTW. There are two things that I know of that will drive the IDE/java insane in that way. One is the unmatched quote.
The other is the unterminated block comment - i.e. if you have /* but the */ is missing.

Pete