हैलो दोस्तों ,
इस ब्लाॅग में edge & obstacle avoiding robot की coding एवं circuit diagram किस प्रकार से होता है इस ब्लाॅग में show किया गया है ।
इसका सर्किट का कनेक्शन कुछ इस प्रकार से हुआ है-
Circuit में कुछ समझ न आया हो तो YouTube के comment box में comment करके पुछ सकते हैं
इसकी coding c language में कुछ इस प्रकार से हुई है-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <Servo.h> // servo library
Servo servo;
#define trigpin 6
#define echopin 7
#define rightm1 2
#define rightm2 3
#define leftm1 4
#define leftm2 5
#define buzzer 13
#define irsensor 9
long duration, distance;
int sensorval;
int angle;
#include <SPI.h> //Oled library
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(-1);
void setup()
{ pinMode(trigpin,OUTPUT);
pinMode(echopin,INPUT);
pinMode(rightm1,OUTPUT);
pinMode(rightm2,OUTPUT);
pinMode(leftm1,OUTPUT);
pinMode(leftm2,OUTPUT);
pinMode(buzzer,OUTPUT);
pinMode(irsensor,INPUT);
servo.attach(8);
display.begin(SSD1306_SWITCHCAPVCC,0x3C);
}
void loop()
{
sensorval = digitalRead(irsensor);
if (sensorval == LOW){
digitalWrite(trigpin,LOW); //pulse
delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
digitalWrite(trigpin,LOW);
duration = pulseIn(echopin,HIGH);
distance = duration*0.034/2;
if (distance>22){ digitalWrite(rightm1,LOW); // Farward
digitalWrite(rightm2,HIGH);
digitalWrite(leftm1,LOW);
digitalWrite(leftm2,HIGH);
display.clearDisplay(); // for oled
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Hello...");
display.display() ;
}
if (distance<21)
{
tone(buzzer,1340,500);
digitalWrite(rightm1, LOW); //Stop
digitalWrite(rightm2, LOW);
digitalWrite(leftm1, LOW);
digitalWrite(leftm2, LOW);
display.clearDisplay(); // for oled
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(20,10);
display.println("Object");
display.display() ;
for(int i = 0;i<3;i++) //head rotation
{
for(angle = 90; angle<120; angle++){
servo.write(angle);
delay(8) ; }
for (angle = 120;angle>90; angle--)
{servo.write(angle);
delay(8); } }
delay(1500);
servo.write(110) ; //see straight
digitalWrite(rightm1, HIGH);//moveback
digitalWrite(rightm2, LOW);
digitalWrite(leftm1, HIGH);
digitalWrite(leftm2, LOW);
delay(500);
digitalWrite(rightm1, LOW); //Stop
digitalWrite(rightm2, LOW);
digitalWrite(leftm1, LOW);
digitalWrite(leftm2, LOW);
delay(500);
digitalWrite(rightm1, LOW);//right
digitalWrite(rightm2, LOW);
digitalWrite(leftm1, LOW);
digitalWrite(leftm2, HIGH);
delay(500);
}}
else{
digitalWrite(rightm1, LOW); //Stop
digitalWrite(rightm2, LOW);
digitalWrite(leftm1, LOW);
digitalWrite(leftm2, LOW);
tone(buzzer,462,500);
display.clearDisplay(); // for oled
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Edge");
display.display() ;
for(int j = 0;j<3;j++) //head rotation
{
for(angle = 120; angle<160; angle++){
servo.write(angle);
delay(8) ; }
for (angle = 160;angle>120; angle--)
{servo.write(angle);
delay(8); } }
delay(1500);
servo.write(110) ; //see straight
digitalWrite(rightm1, LOW); //leftmback
digitalWrite(rightm2, LOW);
digitalWrite(leftm1, HIGH);
digitalWrite(leftm2, LOW);
delay(500);}}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
इस code को आप सीधे ही copy & paste कर सकते हैं👆
इस रोबोट full video👇👇
https://youtu.be/hW8kEaZgOxk
Code ka image👇
इसकी पूरी जानकारी जल्द ही आने वाली है-