I am new to Arduino and building a Useless Box I got the code off the net and typed it in, I am getting an error ButtonPin not declared. can someone please help?
Thanks
#include <Servo.h>
const int button = 2;
int buttonState = 0;
Servo myservo;
int pos;
long timedelay;
void setup()
{
pinMode(buttonPin, INPUT);
myservo.attach(9);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
for(pos = myservo.read(); pos >=20; pos -= 1) {
myservo.write(pos);
timedelay = random(15, 30);
delay(15);
}
}
esle{
timedelay = random(1, 4);
for(pos = myservo.read(); pos <=90; pos += timedelay) {
myservo.write(pos);
}
}
}