# include <servo.h>
servo myservo;
int sw = 5;
int angle = O;
long bounceStartTime = 0 ;
long debounce =50;
void setup()
{
myservo.attach(3);
pinMode(sw,INPUT_PULLUP);
}
void loop()
{
if(digitalRead(sw) == LOW)
{
if(bounceStatTime == 0)
{
bounceStartTime = millis() ;
}
if(millis() - bounceStartTime > debounce)
{
angle += 15 ;
if(angle > 180{
angle = 0;
}
myservo.write(angle);
bounceStartTime = 0;
delay(1000) ;
}
}
}
지니어스 우노 컴파일 오류떠요 해결방안좀 알려주세요
|