Hi I have a problem with my code, could you help me?
What I want it to do is that you press a button once and then the led blinks and repeat this x amount of times and then stop until i press it button again.
Here is the error that i get.
Arduino:1.8.19 (Windows 10), Kort:"Arduino Uno"
y:12:13: error: expected initializer before '}' token
void loop() }
^
y:12:13: error: expected declaration before '}' token
exit status 1
expected initializer before '}' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
const byte buttonPin = 4;
boolean buttonState = LOW;
boolean oldbuttonState = LOW;
void setup()
{
Serial.begin(9600);
pinMode(buttonPin, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (oldbuttonState != buttonState)
{
if (buttonState == HIGH) // button went from off to on
{
for (int x = 0; x < 10; x++) {
digitalWrite(13, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(100);
}
oldbuttonState = buttonState;
}
}