I keep getting the following error "'microsecondsToCentimeters' was not declared in this scope". I'm still relatively new to arduino but I have no idea where the error might be in this one.
This is the part of the programm spitting the error out.
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(inPin, INPUT);
duration = pulseIn(inPin, HIGH);
cm = microsecondsToCentimeters(duration);
Serial.println(cm, DEC);
delay(100);
int sensorValue4 = cm;
Serial.println(sensorValue4);
delay(1);
if(sensorValue0 < 270 && sensorValue4 > 12)
{
digitalWrite(7, HIGH);
}
else
{
digitalWrite(7, LOW);
digitalWrite(4, HIGH);
delay(500); t
digitalWrite(4, LOW);
delay(500);
}
We don't look at 'part of a program'.
Always show us your current compete sketch. Use CTRL T to format the sketch. Please use code tags. Use the </> icon in the posting menu.
[code] Paste sketch here. [/code]
.
As requested here's the entire programm formated
int pingPin = 3;
int inPin = 2;
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
int sensorValue0 = analogRead(A0);
Serial.println(sensorValue0);
delay(1);
long duration, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(inPin, INPUT);
duration = pulseIn(inPin, HIGH);
cm = microsecondsToCentimeters(duration);
Serial.println(cm, DEC);
delay(100);
int sensorValue4 = cm;
Serial.println(sensorValue4);
delay(1);
if (sensorValue0 < 270 && sensorValue4 > 12)
{
digitalWrite(7, HIGH);
}
else
{
digitalWrite(7, LOW);
digitalWrite(4, HIGH);
delay(500); t
digitalWrite(4, LOW);
delay(500);
}
//loop fuer CNY-70 Rechts
int sensorValue2 = analogRead(A2);
Serial.println(sensorValue2);
delay(1);
if (sensorValue2 > 500 && digitalRead(8) == LOW)
{
digitalWrite(9, HIGH);
delay(0);
digitalWrite(5, HIGH);
delay(250);
}
else
{
digitalWrite(9, LOW);
}
//loop für CNY-70 Links
int sensorValue1 = analogRead(A1);
Serial.println(sensorValue1);
delay(1);
if (sensorValue1 > 500 && digitalRead(9) == LOW)
{
digitalWrite(8, HIGH);
delay(0);
digitalWrite(6, HIGH);
delay(250);
}
else
{
digitalWrite(8, LOW);
}
//loop für CNY-70 mitte
int sensorValue3 = analogRead(A4);
Serial.println(sensorValue3);
delay(1);
if (sensorValue3 > 500 && digitalRead(9) == LOW)
{
digitalWrite(6, HIGH);
}
else
{
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
}