Hi folks
Having a compiling issue, with the seemingly standard 'expected unqualified-id' error upon compiling.
If anyone could please have a squiz at my code and see where the (quite likely very simple) problem is I'd be very grateful.
I've Googled until my vision went blurry and still cannot see the problem
/*----- Code for Drew's proximity sensor -----*/
//Define pins
const int pingPin = 7;
const int echoPin = 6;
const int RedLEDpin = 12;
const int GrnLEDpin = 13;
//Start of setup code
void setup() {
Serial.begin(9600);
}
//Start of loop code
void loop() {
long duration, inches, cm;
String BangOn = "BANG ON THE CLIP!";
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
if (inches < 2)
{
digitalWrite(GrnLEDpin, HIGH);
digitalWrite(RedLEDpin, LOW);
Serial.print(BangOn);
delay(1000);
digitalWrite(GrnLEDpin, LOW);
}
long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
return microseconds / 29 / 2;
}
Probably an errant curly bracket or summat.
Millions of thank in advance,
Drew