LED light is continously turned on

Hello everyone , I made one piezoelectric sensor in which Light should flash on tapping the piezo disc. Everything was working good , then I did not used the setup for 30 days. Now I am trying to operate , It is not working . Problem is Its LED light is continously flashing without even touching the piezo disc.
Please suggest how to do solve this .
I have attached the image also in attachment.

Breadboard connection problem. Try soldering the wires.

Paul

Should I change the breadboard or the connection points in the breadboard?
Previously with the same connection points it worked though.

LEDs need current limiting resistors ! ! ! try 220Ω

The green wire is not connected to anything.

Connecting Green wire firmly helped to turn off the LED ,but now the LED is not responding on tapping the sensor disk .The LED flashed just once after uploading the code .

Have you considered that the code may be at fault and that it is going to be difficult to troubleshoot the well formatted code in code tags that you did not post?

Here is the code

int led=4;
int sensor=A0;
int threshold=400;
void setup() {
  pinMode(4,OUTPUT);
  pinMode(A0,INPUT);
 Serial.begin(9600);
}

void loop() {
  int value=analogRead(sensor);
  if (value>=threshold)
  {
    digitalWrite(4, HIGH);
    delay(100);
    
  }
  else
  digitalWrite(4, LOW);
  Serial.println(value);
}

I take it the hall sensor is on the A0 pin?

void loop() {
  int value=analogRead(sensor);
Serial.print( "Threshold = " );
Serial.print( threshold );
Serial print( " value = " )
Serial.println( value );
  //if (value>=threshold)
  //{
   // digitalWrite(4, HIGH);
   // delay(100);
   //
  //}
  //else
  //digitalWrite(4, LOW);
  //Serial.println(value);
//}

Does the sensor values print out as you press on the piezo?

Did the values get to or exceed threshold?

Intermittent behaviour is usually a sign of an intermittent connection - reseat all the connections?

Try to put a resistor parallel to the piezo, start playing with values of 1M and then reduce. The less is the resistor the less is the sensitivity. You are picking up noise from the electrical grid most probably. Also do not hit the piezo hard if you do not want to burn your Digital input pin, or your in series resistor you have put should be >1K.
Actually the "pin" of your piezo plate you are measuring is UNCONNECTED, let me share you a piece of my new book on this in the attachment. (hope you like it, it is this one: Practical Electronics and Arduino in 8 Hours 2020 edition )
Hopes to work! Come back with more info if not solved
Jim

Typo. I believe you meant "tie" here not "tight".

Yes you can ‘tie one on’ :).

By connecting that green wire in the circuit to the positive end of the disk it started functioning
Thanks for everyone's help.

CrossRoads:
Typo. I believe you meant "tie" here not "tight".

Super correct, super thanks !!!!!!!!!! :slight_smile: