Kindly help me in the Arduino code as I am new in this field. I have Arduino code that turns the light in bulb ON and OFF using toggle switch. It is successfully running and giving output.

The following is the code:

```
int buttonPinBulb = 11;
int relay1 = 10;

void setup() {
  pinMode(buttonPinBulb, INPUT_PULLUP);
  pinMode(relay1, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  int buttonBulb = digitalRead(buttonPinBulb);

  if(buttonBulb == HIGH){
    digitalWrite(relay1, HIGH);
  } else {
    digitalWrite(relay1, LOW);
  }
  Serial.println(buttonBulb);
}

```

**Before following suggestion in the comment, the output was:**

[![when switch is OFF](https://i.stack.imgur.com/hCTfO.png)](https://i.stack.imgur.com/hCTfO.png)

[![when switch is ON](https://i.stack.imgur.com/7viz1.png)](https://i.stack.imgur.com/7viz1.png)

**Issue**

Bulb is turning ON and OFF when I toggle switch ON and OFF, and the output is showing on serial monitor continuously. But I want only one value that is not repeated. Like if I toggle the switch ON, then the value shown on serial monitor should be 1 and not 11111111....

Please help me about that. How can I do that?

**After following suggestion in the comment, the code is:**

```
int buttonPinBulb = 11;
int relay1 = 10;
int buttonBulb;
void setup() {
  pinMode(buttonPinBulb, INPUT_PULLUP);
  pinMode(relay1, OUTPUT);
  Serial.begin(115200);
  Serial.println(buttonBulb);
}

void loop() {
  // put your main code here, to run repeatedly:
  buttonBulb = digitalRead(buttonPinBulb);

  if(buttonBulb == HIGH){
    digitalWrite(relay1, HIGH);
  }else{
    digitalWrite(relay1, LOW);
  }
 //Serial.println(buttonBulb);
}

```

**And the output was:**
[![either the switch is OFF or ON the value is the same it should change when I switch ON](https://i.stack.imgur.com/o3mdN.png)](https://i.stack.imgur.com/o3mdN.png)