-
-
Save ulitiy/5c319f65c419dfa1af7ca2dcdebab3ce to your computer and use it in GitHub Desktop.
#include <Servo.h> | |
Servo myservo; | |
const int servoPin = 9; | |
const int buttonPin = 12; | |
const int ledPin = 13; | |
void setup() { | |
myservo.attach(servoPin); | |
pinMode(buttonPin, INPUT); | |
digitalWrite(buttonPin, HIGH); | |
pinMode(ledPin, OUTPUT); | |
digitalWrite(ledPin, LOW); | |
myservo.write(180); | |
delay(1000); | |
myservo.detach(); | |
} | |
void loop() { | |
int buttonVal = digitalRead(buttonPin); | |
if(buttonVal == LOW) { | |
myservo.attach(servoPin); | |
myservo.write(30); | |
delay(575); | |
myservo.write(180); | |
delay(1500); | |
myservo.detach(); | |
delay(5000); | |
} | |
delay(13); | |
} |
Nice implement. I am confused how it is working though. You first have your servo rotate 30 deg, then wait 575 ms and then rotate 180. Why does it rotate in the opposite direction? Wouldn't the servo go on rotating in the same direction? Thanks.
Nice implement. I am confused how it is working though. You first have your servo rotate 30 deg, then wait 575 ms and then rotate 180. Why does it rotate in the opposite direction? Wouldn't the servo go on rotating in the same direction? Thanks.
This code is not for continuous but for a typical servo. So 30 means rotate to 30 degrees and 180 is rotate to 180 degrees. If you use continuous servo 30 (or 0) means rotate counter-clockwise, 90 means stand still, 180 means rotate clockwise.
Got it. Thanks for explaining! Love your cat:)
1.is arduino uno is the same as urs?
2.Is there a different between 180 degree and 360 degree 996 servo motor. Imean which one do i need to buy?
3.how do i make it feed my cat every 1 hour?
1.is arduino uno is the same as urs?
You can use any board with PWM
2.Is there a different between 180 degree and 360 degree 996 servo motor. Imean which one do i need to buy?
360 is better
3.how do i make it feed my cat every 1 hour?
You program it. It's not that hard and is a great skill to have.
I have few more question for that push to get food cat feeder.
1.wut wire did u use?
2.Wut type of micro switch did u use for the button?
Im tryna do this cat feeder for my school project, would really appreciate if u reply =D
I have few more question for that push to get food cat feeder.
1.wut wire did u use?
2.Wut type of micro switch did u use for the button?
Im tryna do this cat feeder for my school project, would really appreciate if u reply =D
It doesn't matter, both are just pieces of conductor, you can use any.
Google for breadboard jumper wires, male-male are fine for arduino uno. Also you don't need a button if you just make it timer-based.
I need a button because i wanna do the push to get food cat feeder. What type of microswitch do i need to use?
Is that code for the push to get food cat feeder?
Wut type of microswitch do i need to use and is tbis code for push to get food cat feeder. Would really aprreciate if u reply.=)
Wut type of microswitch do i need to use and is tbis code for push to get food cat feeder. Would really aprreciate if u reply.=)
I already answered that it doesn't matter, use whatever button you want. Please stop spamming.
this is cool ;0
Idk what im doing wrong but its a continous loop for me. I would like to stop it after accessing the button but it does not stop. Can anyone help me please?
u just change the code
Why did he use in the if Statment LOW and not HIGH
Why did he use in the if Statment LOW and not HIGH
arduino has internal pull up resistor, it's activated on line 12. It doesn't have pull down resistors.
Hi, Thank you for the program. It is super helpful and easy to understand. I am trying to create this for my dog. I feed him twice a day. I don't want him to keep pressing and keep getting food. How can i change the program so that after morning feed (~8AM), it does not dispense food till 5 PM?
Hi, Thank you for the program. It is super helpful and easy to understand. I am trying to create this for my dog. I feed him twice a day. I don't want him to keep pressing and keep getting food. How can i change the program so that after morning feed (~8AM), it does not dispense food till 5 PM?
https://gist.github.com/ulitiy/25d675591af73f347926b7a4e6921797
Have a look at this
that code is suit for sg90 servo?
that code is suit for sg90 servo?
Yes but it's weak.
@TuRQu85
digitalWrite(buttonPin, HIGH);
in your setup to activate internal pull-up resistor