Sabtu, 22 Oktober 2016

HC-SR501 PIR (Passive InfraRed) Motion Sensor Module

HC-SR501 PinOuts and Controls
Pin or ControlFunction
Time Delay AdjustSets how long the output remains high after detecting motion.... Anywhere from 5 seconds to 5 minutes.
Sensitivity AdjustSets the detection range.... from 3 meters to 7 meters
Trigger Selection JumperSet for single or repeatable triggers.
Ground pinGround input
Output PinLow when no motion is detected.. High when motion is detected. High is 3.3V
Power Pin5 to 20 VDC Supply input

Device Area of Detection

Time Delay Adjustment

HC-SR501 Connection to Arduino

Arduino Sketch
int ledPin = 13;  // LED on Pin 13 of Arduino
int pirPin = 7; // Input for HC-SR501
int pirValue; // Place to store read PIR Value
void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);

  digitalWrite(ledPin, LOW);
}
void loop()
{
  pirValue = digitalRead(pirPin);
  digitalWrite(ledPin, pirValue);
}

Sumber
Arduino HC-SR501 Motion Sensor Tutorial

Where to buy
HC-SR501 PIR Motion Sensor Module

HC-SR501 PIR Motion Sensor Module

Senin, 17 Oktober 2016

KY-040 Rotary Encoder Module

KY-040 Rotary Encoder
KY-040 Rotary Encoder PinOut
Keyes Rotary Encoder Schematic
KY-040 Evaluation Circuit
KY-04 Connection to the Arduino
Arduino Sketch
int pinA = 3;  // Connected to CLK on KY-040
int pinB = 4;  // Connected to DT on KY-040
int encoderPosCount = 0;
int pinALast; 
int aVal;
boolean bCW;
void setup()
{
 
pinMode (pinA,INPUT);
  
pinMode (pinB,INPUT);
  
/* Read Pin A
  Whatever state it's in will reflect the last position   
  */
  pinALast = digitalRead(pinA);
  
Serial.begin (9600);
}

void loop()
{
  aVal = 
digitalRead(pinA);
  
if (aVal != pinALast)
  {
    // Means the knob is rotating
    // if the knob is rotating, we need to determine direction
    // We do that by reading pin B.
    if (digitalRead(pinB) != aVal)
    { 
      // Means pin A Changed first - We're Rotating Clockwise
      encoderPosCount ++;
      bCW = 
true;
    }
    else
    {
      // Otherwise B changed first and we're moving CCW
      bCW = false;
      encoderPosCount--;
    }
    
Serial.print ("Rotated: ");
    
if (bCW)
    {
      
Serial.println ("clockwise");
    }
    else
    {
      
Serial.println("counterclockwise");
    }
    
Serial.print("Encoder Position: ");
    
Serial.println(encoderPosCount);
  }
  pinALast = aVal;
}

Sumber
Keyes KY-040 Arduino Rotary Encoder User Manual

Where to buy
KY-040 Rotary Encoder Module


Mukaddimah

BismillaahirRahmaanirRahiim

alHamdulillaah blog ini bisa dibuat. Insha ALLAH kedepannya blog ini akan diisi dengan tutorial dan cara pengetesan komponen, serta beberapa contoh aplikasi atau proyek. Mudah-mudahan blog ini bisa bermanfaat, Aamiiin...