Crowtail- Knock Sensor

From Elecrow
Jump to: navigation, search

Description

The Crowtail-knock sensor is a piezoelectric sensor that contains a piezoelectric sensing crystal and a resister. This crystal creates a small amount of voltage when shaken and takes advantage of this unique property. It will output a pulse when vibration is detected.

Model::CRT00516K

Crowtail- Knock Sensor.jpg

Features

  • Digital Crowtail connector
  • Presence Sensing: Vibration
  • Sensor: KY-031
  • 5v power supply
  • Dimensions(mm):20.0(L)x20.0(W)x7.1(H)

User

1.The Knock sensor have a digital interface, you just only connect it to D3 of Crowtail base shield, connect the LED to D2 of Crowtail base shield.

Knock Sensor11.jpg

Then upload the code to Crowduino board.


int Led = 2 ; // define LED Interface
int Shock = 3; // define the percussion Sensor Interface
//int val; // define numeric variables val
 
void setup ()
{
  pinMode (Led, OUTPUT) ; // define LED as output interface
  pinMode (Shock, INPUT) ; 
  Serial.begin(9600);// define knock sensor output interface
}
void loop ()
{
 int val = digitalRead (Shock) ;// read digital interface is assigned a value of 3 val
 Serial.println(val);
  if (val == HIGH) // When the percussion when the sensor detects a signal, LED flashes
  {
    digitalWrite (Led, HIGH);
    delay(500);
  }
  else
  {
    digitalWrite (Led, LOW);
  }
}

Now, knock the sensor and the LED attached to pin 2 on the Crowtail board will light up.

Personal tools
Namespaces

Variants
Actions
Elecrow Store
Navigation
Elecrow Products
Toolbox