besties_blankabotz
Published © GPL3+

SM Ultra Detect Bot

An ultrasonic object-detecting robot with safe and danger signals... in a new model designed by Sohail Memon (@BLANKABOTZ).

IntermediateFull instructions provided2 hours874
SM Ultra Detect Bot

Things used in this project

Story

Read more

Schematics

SCHEMATIC SM

CONNECTIONS

Code

Sm bot code

C/C++
Bot Code
/* AN ULTRAONIC BOT CODE BY SOHAIL MEMON-911050119....CREATED ON .....BEST EVER SIMPLE BOT CODE*/ 
 
 
 #define trigPin 10
 
#define echoPin 11

#define led 9

void setup()

{ Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(led, OUTPUT);

pinMode(8,OUTPUT);
}

void loop()

{ long duration, distance;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

if (distance < 10)

{ digitalWrite(led,HIGH);
  digitalWrite(8,LOW);

}

else {

digitalWrite(led,LOW);
digitalWrite(8,HIGH);

}

Serial.print(distance);

Serial.println(" cm");

delay(500);

}

Credits

besties_blankabotz
0 projects • 2 followers

Comments