Sunday, May 17, 2020

Servo Motor SG-90 Interfacing with Arduino Uno By Engr.Habib Ur Rehman


 
                  Servo Motor SG-90 Interfacing
                  with Arduino Uno
                 By Engr.Habib Ur Rehman

Components/Equipment Required:
            Following Components/Equipment are required to perform task.
2.    Servo Motor SG-90 (https://piees.pk/product/sg-90-servo-motor/)
3.    Breadboard
Circuit Diagram:
Arduino Program:
#include <Servo.h>
int servoPin = 9;
Servo servo; 
int servoAngle = 0;
void setup()
{
  servo.attach(servoPin);
}
void loop()
{
   servo.write(45);
   delay(1000);
   servo.write(90);
   delay(1000);
   servo.write(135);
   delay(1000);
   servo.write(90);
   delay(1000);
  {                                 
    servo.write(servoAngle);             
    delay(50);                 
  }
  for(servoAngle = 180; servoAngle > 0; servoAngle--)
  {                                
    servo.write(servoAngle);         
    delay(10);     
  }
}

Monday, May 11, 2020

Single Relay Interfacing with Arduino Uno By Engr.Habib Ur Rehman


 
                  Single Relay Interfacing
                  with Arduino Uno
                 By Engr.Habib Ur Rehman

Components/Equipment Required:
            Following Components/Equipment are required to perform task.
2.    Single Channel Relay Module (https://piees.pk/?s=relay&post_type=product)
4.    Breadboard

Circuit Diagram:
Note: If you connect with “Normally Open” then output will be first “High” then it will be “Low” and If you connect with “Normally Close” then output will be first “Low” then it will be “High”
Arduino Program:
int relay = 10;
void setup ()
{
  pinMode (relay, OUTPUT);
}
void loop ()
{
  digitalWrite (relay, HIGH);
  delay (1000);
  digitalWrite (relay, LOW);
  delay (1000);
}

Sunday, May 3, 2020

Ultrasonic Sensor Interfacing with Arduino Uno By Engr.Habib Ur Rehman


Ultrasonic Sensor Interfacing
 with Arduino Uno
    By Engr.Habib Ur Rehman


Components/Equipment Required:
            Following Components/Equipment are required to perform task.
3.    Breadboard
Circuit Diagram:
Arduino Program:
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, LOW);
delay(200);
digitalWrite(trigPin, HIGH);
delay(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
Serial.print("Distance");
Serial.println(distance);
}