受晶片供應影響,PI / micro:bit / Jetson供貨及價格較為浮動,敬請見諒。

KY-031 敲擊傳感器 Knock Sensor Module

$15.00

貨號: KY-028 分類: ,

描述

KY-031 KNOCK SENSOR MODULE

Description

KY-031 knock sensor module. A vibration sensor that sends a signal when a knock/tap is detected.

Compatible with Arduino, ESP8266, ESP32, Teensy, Raspberry Pi, and other popular platforms.

  • KY-031 Knock Sensor Module

  • KY-031 Fritzing custom part image

KY-031 Specifications

This module consists of a 10 kΩ resistor and a spring-based sensor that sends a high signal when a vibration is detected.

Operating Voltage 3.3V to 5V
Output Type Digital

KY-031 Connection Diagram

Connect the module’s Power line (middle) and the ground (-) to +5 and GND respectively. Connect signal (S) to pin 3 on the Arduino.

KY-031 Arduino
S Pin 3
middle +5V
GND
Arduino KY-031 Knock sensor module connection diagramclick to enlarge

KY-031 Example Code

The following sketch will turn on the LED on the Arduino’s pin 13 when the module detects vibration caused by knocking or tapping the sensor.

int Led = 13;	// LED on Arduino board 
int Shock = 3;	// sensor signal
int val;		// numeric variable to store sensor status

void setup()
{
	pinMode(Led, OUTPUT); 	// define LED as output interface
	pinMode(Shock, INPUT); 	// define input for sensor signal
}

void loop()
{
	val = digitalRead(Shock); // read and assign the value of digital interface 3 to val
	if(val == HIGH) // when sensor detects a signal, the LED flashes
	{
		digitalWrite(Led, LOW);
	}
	else
	{
		digitalWrite(Led, HIGH);
	}
}

商品評價

目前沒有評價。

只有註冊並且購買過商品的顧客才能撰寫評價。