To drive the servo, two push buttons and a potentiotemers is being used. Push Buttons are for increasing/decreasing the speed/delayTime of the servo whereas the potentiometer is in charge to manipulate direction/location of the servo.
The circuit diagrams (one made on digital environment, the other one is the implemented) and the datasheet of shift register can be seen below:
Digital Drawed Circuit
Implemented Circuit
Here is a video available to see the outputs and how the system works:
Arduino Code :
/* Can KAVALOĞLU */ #include <Servo.h> Servo myservo; int potPin = 0; int bttn1Pin = 10; int bttn2Pin = 11; int potValue, bttn1Value, bttn2Value, delayTime = 15; void setup(){ pinMode(potPin, INPUT); pinMode(bttn1Pin, INPUT); pinMode(bttn2Pin, INPUT); myservo.attach(9); // attaches the servo on pin 9 to the servo object Serial.begin(9600); } void loop(){ bttn1Value = digitalRead(bttn1Pin); bttn2Value = digitalRead(bttn2Pin); potValue = analogRead(potPin); potValue = map(potValue, 0, 1023, 0, 180); if(bttn1Value == HIGH && bttn2Value == LOW){ if(delayTime > 5) delayTime -= 5; } else if(bttn1Value == LOW && bttn2Value == HIGH){ delayTime += 5; } myservo.write(potValue); Serial.println(potValue); delay(delayTime); }
Hiç yorum yok:
Yorum Gönder