Загрузка страницы

How to combine an Servo and Ultrasonic Sensor and code

This video was created to help people create a Servo and Ultrasonic Sensor

Other Youtube channel Andre ClassicCuts
https://www.youtube.com/channel/UC7CU4ydXEDfnaYhj6ToAjTg

DreThePlug IG: DreThePlug123
https://www.instagram.com/dretheplug123/

Add me on Linkedin
https://www.linkedin.com/in/andre-brown-194918103/

How to Control the Ultra Sonic Sensor Ranges with Sound/Music Arduino
https://youtu.be/4I6jkPBma4M

Music provided by isthatCaydo?.
Instrumental: Reprod. by Caydo
Channel: https://www.youtube.com/watch?v=-l92PxYmRa0
Note servo wires colors
Brown-GND
Red-VCC
Orange-PWM aka Signal
The Treasure Chest
int trigPin = 3;
int echoPin = 2;
#include (less than sign)Servo.h(greater than sign)
Servo servo1;
Servo servo2;
int angle = 0;

void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT); // put your setup code here, to run once:
servo1.attach(4);
servo1.write(angle);
servo2.attach(12);
servo2.write(angle);
}

void loop() {
long duration, distance;
digitalWrite(trigPin,HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
duration=pulseIn(echoPin, HIGH);
distance =(duration/2)/29.1;
Serial.print(distance);
Serial.println("CM");
delay(10);

if (distance (less than sign) 30) {
servo1.write(90);
servo2.write(0);
}
else {
servo1.write(0);
servo2.write(90);
}
}

Видео How to combine an Servo and Ultrasonic Sensor and code канала DreThePlug
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
17 июля 2020 г. 17:00:12
00:10:33
Яндекс.Метрика