Skip to main content

Posts

Showing posts from February, 2020

Make robot at home

Make robot at home Circuit Diagram Code   #include <AFMotor.h> #include <NewPing.h> #include <Servo.h> #define TRIG_PIN A0 #define ECHO_PIN A1 #define MAX_DISTANCE 200 #define MAX_SPEED 150 // sets speed of DC motors #define MAX_SPEED_OFFSET 20 NewPing sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE); AF_DCMotor motor1(1, MOTOR12_1KHZ); //AF_DCMotor motor2(2, MOTOR12_1KHZ); //AF_DCMotor motor3(3, MOTOR34_1KHZ); AF_DCMotor motor4(4, MOTOR34_1KHZ); Servo myservo; boolean goesForward=false; int distance = 100; int speedSet = 0; void setup() { myservo.attach(10); myservo.write(115); delay(1000); distance = readPing(); delay(100); distance = readPing(); delay(100); distance = readPing(); delay(100); distance = readPing(); delay(100); } void loop() { int distanceR = 0; int distanceL = 0; delay(40); if(distance<=15) { moveStop(); delay(100); moveBackward(); delay(300); moveStop(); delay(20...