Help!! Am Getting A Error I Cant Resolve Any Help Would Be Loved At This Point!

Hello All And today I Have This Error To Tackle: "A function-definition is not allowed here before '{' token"

The Full Code Is:

const int pingPin =7 ;
const int ledPin = 5;
const int runingLEDpin = 4;
const int cableLight = 2;

void setup() {
Serial.begin(9600);
pinMode(runingLEDpin, OUTPUT);
pinMode(cableLight, OUTPUT);
pinMode(ledPin, OUTPUT);


void loop() {
long duration, inches, cm;

pinMode(pingPin,OUTPUT);
digitalWrite(pingPin,LOW);
delayMicroseconds(2);
digitalWrite(pingPin,HIGH);
delayMicroseconds(5);
digitalWrite(pingPin,LOW);
}

pinMode(pingPin,INPUT);
duration =pulseIn(pingPin,HIGH);

inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);

if (inches <= 47){
  ledPULSE();
  digitalWrite(cableLight, HIGH);
}else{
  runingLED();
  delay(15000);
  digitalWrite(cableLight, LOW);
}
long microsecondsToInches(long microseconds)
{
return microseconds /74/2;
}

long microsecondsToCentimeters(long microseconds)
{
return microseconds /29/2;
}

void runingLED(){
  digitalWrite(runingLEDpin, HIGH);
  delay(1555);
  digitalWrite(runingLEDpin, LOW);
  delay(2599);
}

void ledPULSE(){
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
}

How ever! I Think I Know The Section Of The Code It Is In.

inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);

if (inches <= 47){
  ledPULSE();
  digitalWrite(cableLight, HIGH);
}else{
  runingLED();
  delay(15000);
  digitalWrite(cableLight, LOW);
}
long microsecondsToInches(long microseconds)
{
return microseconds /74/2;
}

long microsecondsToCentimeters(long microseconds)
{
return microseconds /29/2;
}

Hummmm Well I Will Admit This Has Got Me Stumped So If Any Of you Guys Out There Can Help I Would Realy Enjoy Some Right Now!

Thanks,

Carter B.

const int cableLight =

assigned what?

I'm curious to know how you figured that a "Programming" question should be asked in the "Website and Forum" section?

I'm also curious to know whether you examined your code carefully and how you concluded that this incomplete line would be acceptable to the compiler

const int cableLight =

...R

Editing the original post to remove the error now makes it impossible to tell you what your problem is.
Please don't do this.

Is tHere somEthing wrOng witH yoUr shIft-keY, or are you German, and capitalise all Nouns?

Apart from the previously pointed out error your missing a } before

long microsecondsToInches(long microseconds)

Hi, your void setup() is also missing a }.
Please select Tools and then AutoFormat to tidy up your layout.
It will also tell you if you have the right number of { and }.
Then repost your code, please do not correct an earlier posted code.

Thanks Tom....... :slight_smile: