Rabu, 02 November 2016

KY-031 Knock Impact Sensor Module


KY-031 Knock Impact Sensor Module

KY-031 Knock Sensor PinOuts
KY-031 Knock Sensor Module Schematic
KY-031 Connection to the Arduino
Arduino Sketch
int knockPin = 10; // Use Pin 10 as our Input
int knockLED = 13;
int knockVal = HIGH; // This is where we record our shock measurement
boolean bAlarm = false;unsigned long lastKnockTime; // Record the time that we measured a shock

int knockAlarmTime = 500; // Number of milli seconds to keep the knock alarm high

void setup ()
{
  
Serial.begin(9600); 
  
pinMode (knockPin, INPUT); // input from the KY-031
    pinMode (knockLED, OUTPUT);
}

void loop ()
{
  knockVal = 
digitalRead (knockPin); // read KY-031 Value

  
if (knockVal == LOW) // If we see a knock
  {

    lastKnockTime = 
millis(); // record the time of the shock
    // The following is so you don't scroll on the output screen
    if (!bAlarm)
    {
      
Serial.println("KNOCK, KNOCK");
      digitalWrite (knockLED, HIGH);
      bAlarm = 
true;
    }
  }
  
else
  {
    
if( (millis()-lastKnockTime) > knockAlarmTime  &&  bAlarm)
    {
      
Serial.println("no knocks");
      digitalWrite (knockLED, LOW);
      bAlarm = 
false;
    }
  }
}


Sumber
Keyes KY-031 Arduino Knock Impact Sensor: Manual and Tutorial

Where to Buy
KY-031 Percussion Knock Impact Sensor Module

KY-031 Percussion Knock Impact Sensor Module

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...