How to control servo motor with ultrasonic Sensor using Arduino Arduino tutorial #5 This is the the Circut diagram of this tutorial This is the code of this tutorial #include <Servo.h> Servo servo1; int trigPin = 9; int echoPin = 8; long distance; long duration; void setup() { servo1.attach(7); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); } void loop() { ultra_sonic(); servo1.write(90); if(distance <=9) { servo1.write(270); } } void ultra_sonic() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration*0.034/2; } Thank you for watching the video and the visiting this blog . if you have any quarries kindly type it in the comments Thank you
the circut for the talking robot code for the talking robot int motorPlus = 5; int motorMinus = 4; void setup() { pinMode(motorPlus,OUTPUT); pinMode(motorMinus,OUTPUT); } void loop() { digitalWrite(motorPlus,HIGH); digitalWrite(motorMinus,LOW); delay(500); digitalWrite(motorPlus,LOW); digitalWrite(motorMinus,HIGH); delay(500); } copy and past this code to arduino and upload it channel link : https://www.youtube.com/channel/UCOgVFoF3Vkw3aicoAjDfRng meet u in next blog
DHT11 Temperature and Humidity sensor Here is the link of the video This is the Circut Diagram This is the code for the project #include "dht.h" #define dht_apin A0 dht DHT; void setup(){ Serial.begin(9600); delay(500);//Delay to let system boot Serial.println("Humidity and Temperature scale"); delay(1000); } void loop(){ DHT.read11(dht_apin); Serial.print("Current humidity = "); Serial.print(DHT.humidity); Serial.print("% "); Serial.print("temperature = "); Serial.print(DHT.temperature); Serial.println("C "); delay(5000); } Thank you for watching the video and the visiting this blog . if you have any quarries kindly type it in the comments Thank you
Comments
Post a Comment