Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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);
}
@szakynr

This comment has been minimized.

Copy link

@szakynr szakynr commented Sep 9, 2017

this is cool code for cat

@linuxgorl

This comment has been minimized.

Copy link

@linuxgorl linuxgorl commented Oct 17, 2017

Thanks

@awintersiii

This comment has been minimized.

Copy link

@awintersiii awintersiii commented Sep 22, 2018

What calls the "loop" function?

@kaledon1998

This comment has been minimized.

Copy link

@kaledon1998 kaledon1998 commented Sep 28, 2018

hi there, where we can find the wiring diagrams?

@jeremyfritzen

This comment has been minimized.

@abigailltm

This comment has been minimized.

Copy link

@abigailltm abigailltm commented Mar 12, 2019

How many times a day does this feed. How do i adjust how much food is delivered. Do i just have to play around with the numbers?

@TuRQu85

This comment has been minimized.

Copy link

@TuRQu85 TuRQu85 commented Feb 25, 2020

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?

@ulitiy

This comment has been minimized.

Copy link
Owner Author

@ulitiy ulitiy commented Feb 26, 2020

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?

@TuRQu85

  1. One button pin should be connected to the ground (ground, not 5V), another one to the button pin.
  2. ensure you have digitalWrite(buttonPin, HIGH); in your setup to activate internal pull-up resistor
  3. show your code please
  4. show your wiring
@szb103

This comment has been minimized.

Copy link

@szb103 szb103 commented Apr 8, 2021

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.

@ulitiy

This comment has been minimized.

Copy link
Owner Author

@ulitiy ulitiy commented Apr 9, 2021

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.

@szb103

This comment has been minimized.

Copy link

@szb103 szb103 commented Apr 9, 2021

Got it. Thanks for explaining! Love your cat:)

@Darwishkun

This comment has been minimized.

Copy link

@Darwishkun Darwishkun commented Apr 29, 2021

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?

@ulitiy

This comment has been minimized.

Copy link
Owner Author

@ulitiy ulitiy commented Apr 29, 2021

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.

@Darwishkun

This comment has been minimized.

Copy link

@Darwishkun Darwishkun commented Jun 18, 2021

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

@ulitiy

This comment has been minimized.

Copy link
Owner Author

@ulitiy ulitiy commented Jun 18, 2021

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.

@Darwishkun

This comment has been minimized.

Copy link

@Darwishkun Darwishkun commented Jun 19, 2021

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?

@Darwishkun

This comment has been minimized.

Copy link

@Darwishkun Darwishkun commented Jun 25, 2021

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.=)

@ulitiy

This comment has been minimized.

Copy link
Owner Author

@ulitiy ulitiy commented Jun 25, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment