Untitled
raw download clone
TEXT
views 9
,
size 643 b
#include <Servo.h> 
int servoPin = 8; 
int buttonPin = 13; 
int buttonRead = 0; 
Servo servo;   
int servoAngle = 0;  
#define buzzer 9 

void setup() 
{ 
  Serial.begin(9600);   
  pinMode(buttonPin, INPUT_PULLUP); 
  pinMode(buzzer, OUTPUT); 
} 

void loop() 
{ 
  buttonRead=digitalRead(buttonPin); 
  Serial.println(buttonRead); 
    delay(100);
  if(buttonRead==1){ 
  digitalWrite(buzzer,LOW); 
  digitalWrite(servoPin, LOW); 
} 

if (buttonRead==0)
{ 
servo.attach(servoPin); 
for(servoAngle = 180; servoAngle > 0; servoAngle--) 
  {
    servo.write(servoAngle);           
  } 
tone(buzzer, 500); 
}
}
close fullscreen
Login or Register to edit or fork this paste. It's free.