HELP BASIC CODE FOR PIEZO KNOCK

Hi guys can you help me....

give programing basic code for my project.

i needed...
if any piezo knock to slow digital out 2.4 and if knock harder digital out raising to 5 volt. and 0 volt if not any energize.

my plan use 10 sensor piezo and all can working together.

please give me basic code, will i explore later, or give me link for this article.

thank you

attached image

bawor:
HELP BASIC CODE FOR PIEZO KNOCK

PLEASE STOP SCREAMING AT US!

bawor:
give programing basic code for my project.

I'm sorry, but that's not how this forum works. You can't just go "give me code" and expect people to give you free code on demand.

We're here to help people when they're stuck on a project, not to write free code for people who are too lazy to do it themselves.

Pieter

More i try the code but not succes. I don't understand yet about programing.

I starting from uno provided,
But if knock light on and knock again knock off some time light only if knock. That is i want it.

I try to explore still fail.

Just help changing code
Light ON if knock only....
and how to make other channel because that is only one output pin 13.

Believe i was traying code 2 days for learning.

This code i use

/* Knock Sensor


  • Program using a Piezo element as if it was a knock sensor.
  • We have to basically listen to an analog pin and detect
  • if the signal goes over a certain threshold. It writes
  • "knock" to the serial port if the Threshold is crossed,
  • and toggles the LED on pin 13.
  • (cleft) 2005 D. Cuartielles for K3
  • edited by Scott Fitzgerald 14 April 2013
    */

int ledPin = 13;
int knockSensor = 0;
byte val = 0;
int statePin = LOW;
int THRESHOLD = 100;

void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}

void loop() {
val = analogRead(knockSensor);
if (val >= THRESHOLD) {
statePin = !statePin;
digitalWrite(ledPin, statePin);
Serial.println("Knock!");

}
delay(100); // we have to make a delay to avoid overloading the serial port
}

if any piezo knock to slow digital out 2.4 and if knock harder digital out raising to 5 volt. and 0 volt if not any energize.

That is not going to happen.

What is your code doing that you don’t want it to?
A threshold of 100 is very low, the range of values is from 0 to 1023, so if you want to trigger greater than 2.5V use a value of 512.