INFRA RED OBSTACLE SENSOR

IR obstacle

int LED = 13; // Use the onboard Uno LED

int isObstaclePin = 7; // This is our input pin

int isObstacle = HIGH; // HIGH MEANS NO OBSTACLE

void setup() {

pinMode(LED, OUTPUT);

pinMode(isObstaclePin, INPUT);

Serial.begin(9600);

}

void loop() {

isObstacle = digitalRead(isObstaclePin);

if (isObstacle == LOW)

{

Serial.println(“OBSTACLE!!, OBSTACLE!!”);

digitalWrite(LED, HIGH);

}

else

{

Serial.println(“clear”);

digitalWrite(LED, LOW);

}

delay(200);

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s