This sketch is maybe want you want, every time you push a button a LED wil turn on, and next time you push itthe LED will turn off.
There is no debouncing , and there should be
int vent=100;
const int buttonPin = 7;
int flag=0;
int buttonState = 0;
void setup()
{
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop()
{
// digitalWrite(4, HIGH);
buttonState = digitalRead(buttonPin);
delay(vent);
Serial.print(buttonState);
Serial.println();
if (buttonState==HIGH){
if (flag==1) {
flag=0;
}
else
{
flag=1;
}
}
if (flag==1){
Serial.print("HIGH\n");
digitalWrite(4, HIGH);
}
if (flag==0){
digitalWrite(4, LOW);
Serial.print("LOW\n");
}
}