Salutations All,
I am having trouble with an error message. I am using an Arduino Uno on version 1.6.11. If someone can look over the code, to tell me how to fix it:
const int pingPin = 7;
void setup() {
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
analogWrite(3,200);
digitalWrite(12, HIGH);
}
void loop() {
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);
if(inches <12){
digitalWrite(9, HIGH);
delay(100);
digitalWrite(8, LOW);
digitalWrite(13, HIGH);
analogWrite(11, 255);
digitalWrite(9, LOW);
digitalWrite(12, LOW);
analogWrite(3,200);
delay(2000);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
else{
digitalWrite(12, HIGH);
digitalWrite(9, LOW);
digitalWrite(3,200);
}
delay(100);
}
long microsecondsToInches(long microseconds);
{
}
"Duration" they say is not declared, and I am not sure how to fix it. Any help appreciated!