why is my LED is not switching off? please help
this is my code

Please post the complete program.

Also please don’t post pictures of text - just copy and paste the code using the code button </>

See How to get the best out of the Forum


<int ButtonValue = 0;
int Button = 3;
int LED = 2 ;

int ButtonValue2 = 0;
int Button2 = 5;
int LED2 = 4 ;

#include <MPU6050_tockn.h>
#include <Wire.h>
MPU6050 mpu6050(Wire);

void setup() {
pinMode (Button, INPUT);
pinMode (LED, OUTPUT);

pinMode (Button2, INPUT);
pinMode (LED2, OUTPUT);


delay (100);

void loop() {{
ButtonValue = digitalRead (Button);
if(ButtonValue != 0){
digitalWrite (LED, HIGH);

{ ButtonValue2 = digitalRead (Button2);
if(ButtonValue2 != 0){
digitalWrite (LED2, HIGH);


Serial.print("\tangleY : “);
Serial.print(”\tangleZ : ");

if ( ((mpu6050.getAngleZ()) < -50))
if ( ((mpu6050.getAngleZ()) >-5))

digitalWrite(LED, LOW);



Please follow the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless