AED 5.00
Description
Unlock the full potential of this Piezo Vibration Sensor as you delve into the realms of vibration sensing and sound generation. Whether you're a novice or an experienced enthusiast, this sensor provides a foundation for a diverse range of exciting projects. Let your creativity flow as you explore the possibilities that the Piezo Vibration Sensor brings to your MCU and Arduino experiments.
Features:
- Dual Functionality: The Piezo Vibration Sensor serves a dual purpose of detecting physical distortions, sound waves, or mechanical strain to produce voltage, and generating sound when a voltage is applied across it. This versatility opens up a myriad of possibilities for creative projects.
- Ideal for Beginners: Designed with beginners in mind, this sensor provides a user-friendly interface for those exploring MCU and Arduino projects. Its simplicity makes it an excellent starting point for hands-on learning.
- Standalone Potential: With the Piezo Vibration Sensor, you can create a multitude of projects without the need for additional components. Its standalone capability allows you to experiment and innovate with ease.
Specifications:
- Resonant Frequency: 4.6 +/- 0.5 kHz
- Resonant Impedance (Ohms): 300 max
- Voltage Range: DC 3-24V
- Material: Copper
Sample Code for Arduino:
This Arduino sketch is designed to leverage a piezo element for detecting knocking sounds. The functionality involves reading an analog pin and comparing the obtained result against a predefined threshold. If the result surpasses this threshold, the sketch sends a "knock" signal to the serial port and toggles the LED connected to pin 13.
Wiring Instructions:
- Connect the positive lead of the piezo to analog pin 0.
- Connect the negative lead of the piezo to the ground.
Additionally:
- Attach a 1-megohm resistor from analog pin 0 to the ground.
This setup enables the Arduino to effectively detect knocks through the piezo element, translating physical impacts into actionable data. The 1-megohm resistor serves as a critical component in the analog pin 0 circuit, contributing to the overall functionality of the knock detection system.
// Constants that won't change: const int LED_PIN = 13; // LED connected to digital pin 13 const int KNOCK_SENSOR = A0; // Piezo connected to analog pin 0 const int THRESHOLD = 100; // Threshold value to determine a knock // Variables that will change: int sensorReading = 0; // Variable to store sensor pin reading int ledState = LOW; // Variable to store last LED status for toggling void setup() { pinMode(LED_PIN, OUTPUT); // Declare LED_PIN as OUTPUT Serial.begin(9600); // Initialize serial communication } void loop() { // Read the sensor and store the value in sensorReading: sensorReading = analogRead(KNOCK_SENSOR); // If the sensor reading is greater than the threshold: if (sensorReading >= THRESHOLD) { // Toggle the status of LED_PIN: ledState = !ledState; // Update the LED pin itself: digitalWrite(LED_PIN, ledState); // Send the string "Knock!" back to the computer, followed by newline Serial.println("Knock!"); } delay(100); // Delay to avoid overloading the serial port buffer }