Go Down

Topic: Exit status Not declared in this scope (Read 39 times) previous topic - next topic

DaisyBristow

exit status 1
'trigPin' was not declared in this scope

This is the message that keeps popping up in my code, not sure how to fix it. Any help would be appreciated - Ill attach the code below.

#define trigPin2
#define echoPin 3
int m11=4;
int m12=5;
int m21=6;
int m22=7;
void setup()
{
  pinMode(m11,OUTPUT);
  pinMode(m12,OUTPUT);
  pinMode(m21,OUTPUT);
  pinMode(m22,OUTPUT);
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
}
void loop()
{
  int duration,distance;
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin,LOW);
  duration=pulseIn(echoPin,HIGH);
  distance=(duration/2)/29.1;
  if(distance>=40)
}
digitalWrite(m11,LOW);
digitalWrite(m12,LOW);
digitalWrite(m21,LOW);
digitalWrite(m22,LOW);
delay(500);

}
else
{
  if(distance>=25)
  {
    digitalWrite(m11,HIGH);
    digitalWrite(m12,LOW);
    digitalWrite(m21,HIGH);
    digitalWrite(m22,LOW);
    delay(400);

  }
  else
  {
    digitalWrite(m11,LOW);
    digitalWrite(m12,HIGH);
    digitalWrite(m21,LOW);
    digitalWrite(m22,HIGH);
    delay(400);
  }
}
}

  }

Whandall

Change
Code: [Select]
#define trigPin2
to probably
Code: [Select]
#define trigPin 2
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

Go Up