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);
}          

Wednesday, April 22, 2020

Sharp Distance Sensor GP2Y0A51SK0F Interfacing with Arduino Uno By Engr.Habib Ur Rehman




                  Sharp Distance Sensor GP2Y0A51SK0F      
                                  Interfacing with Arduino Uno
                 By Engr.Habib Ur Rehman


Components/Equipment Required:
           Following Components/Equipment are required to perform task.
2.    Sharp Distance Sensor GP2Y0A51SK0F (https://piees.pk/product/ir-distance-sensor-gp2y0a41sk0f/)     
3.    Breadboard
                              4.Jumper Wires (https://piees.pk/product-category/jumper-wires/)
Circuit Diagram:


Arduino Program:
#include <SharpIR.h>
#define ir A0
#define model 20150
SharpIR SharpIR(ir, model);
void setup() {
  Serial.begin(9600);}
void loop() {
  delay(2000);  
  unsigned long pepe1=millis();
  int dis=SharpIR.distance();
  Serial.print("Mean distance: ");
  Serial.println(dis);
  unsigned long pepe2=millis()-pepe1;
  Serial.print("Time taken (ms): ");
  Serial.println(pepe2);  }
Note:
·        Sharp IR Master Library folder should be added in Arduino library folder “C:\Program Files\Arduino\libraries”

·        This Module work good for a short distance

Wednesday, July 4, 2018

Led On/Off using HC-05 Bluetooth Module & Arduino Uno


 
                  Led On/Off using HC-05 Bluetooth Module
                  & Arduino Uno
                 By Engr.Habib Ur Rehman


Components/Equipment Required:
            Following Components/Equipment are required to perform task.
2.    HC-05 Bluetooth Module (https://piees.pk/product/hc-05-bluetooth-module/)
3.    Smart Phone
5.    Breadboard
Circuit Diagram:

Arduino Program:
int ledPin=13;
int state=0;
int flag=0;
void setup()
{
 pinMode(ledPin,OUTPUT);
 digitalWrite(ledPin,LOW);
 Serial.begin(9600);
 }
 void loop()
 {
  if(Serial.available()>0)
  {
   state= Serial.read();
   flag=0;
   }
   if (state == '0')
   {
    digitalWrite(ledPin,LOW);
    if(flag==0)
    {
      Serial.println("LED: off ");
      flag=1;
      }
    }
    else if (state == '1')
   {
    digitalWrite(ledPin,HIGH);
    if(flag==0)
    {
      Serial.println("LED: on ");
      flag=1;
      }
    }
  }
Android Application:
            Android application is named as “Bluetooth Terminal HC-05”
            Pairing code is “1234”