I am currently working on a project for a charity display. The project I am working on envolves servos, I have pieced some code together but need to slow the servo down. The circuit involves a push button switch that that is supposed to go from 0 to 90 degrees when pressed and when let go, back to 0. Im not sure how to slow the servo down whilst keeping the button working any help would be greatly appreciated. I will attack code below.
Cheers
Tom
#include <Servo.h> //include the servo library for this program
Servo myservo; //create servo object to control a servo
void setup() //do these things once
{
Serial.begin(9600); //set data transmission rate to communicate with computer
pinMode(8,INPUT_PULLUP); //pin 8 forced to HIGH when there is no external input
myservo.attach(9); //attaches the servo on pin 9 to the servo object
myservo.write(60); //tells servo to go to 60 degree position
}
void loop() //do these things forever
{
while(digitalRead(8)== HIGH)
{
myservo.write(60) //...servo position is 60 degrees
Serial.print("open"); //print the word "open"
Serial.println(""); //print nothing, go to next line
}
myservo.write(150); //otherwise, servo position is 150 degrees
Serial.println(""); //print nothing, go to next line
Serial.println("closed"); //print the word "closed"
Serial.print("waiting 5 seconds"); //print "waiting 5 seconds"
Serial.println(""); //print nothing, go to next line
delay(5000); //waits for 5 seconds before re-doing the loop
}