Hi!..thank you!..i figured out the problem, it was because of wrong resistor value.. ![]()
But I am encountering another problem.
This is my code:
const int motorPin = 3;
const int piezo = A0;Â // the piezo is connected to analog pin 0
int sensorReading = 0;Â Â Â // variable to store the value read from the sensor pin
int sensorMax = 0;
int sensorMin = 1023;
int threshold;
void setup()
{
pinMode(motorPin, OUTPUT);
 Serial.begin(57600);   // use the serial port
//CALIBRATION
 digitalWrite(3, HIGH);
 while (millis() < 3000)
 {
  threshold = analogRead(piezo);
  // record the maximum sensor value
  if (threshold > sensorMax)
  {Â
   sensorMax = threshold;
  }
  if (threshold < sensorMin)
  {
   sensorMin = threshold;
  }
 }
 // signal the end of the calibration period
 digitalWrite(3, LOW);
 threshold = sensorMax;
}
void loop()
{
 // read the sensor and store it in the variable sensorReading:
 sensorReading = analogRead(piezo); Â
Â
 //if within range..run motor
 if ((sensorReading >= threshold) || (sensorReading <= sensorMin))
 {
  Serial.println(sensorReading);
  digitalWrite (motorPin,HIGH);
  delay (1000);
  digitalWrite (motorPin, LOW);
 }
 delay(2000);
}
In this, the motor runs whenever the sensor is within the range specified. But me blowing the sensor and the motor running is not in synced. I am new to coding and stuffs, and I am not able to comprehend what modification needs to be done.