Question: Using the following Arduino code write a complete code that will display into the serial monitor the number of valid knocks (you can choose what

Using the following Arduino code write a complete code that will display into the serial monitor the number of valid knocks (you can choose what is considered a good knock).

When 2 valid claps (or knocks) are detected, turn on an LED. After 2 more knocks, the LED should turn off.

*code for using transducer as a sensor*

const int piezo = a0; // Pin connected to piezo

int knockVal; // Value for knock strength

void setup () {

Serial.begin(9600);

}

void loop () {

knockVal = analogRead(piezo)

if(knockVal > 0){

Serial.println(knockVal);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!