Hello everyone, I need help with my arduino project as I am developing a Pet feeder. The pet feeder will rotate servo and drop food based on the amount of food missing on the plate which is detected by weight sensor. I cant seem to find the code anywhere. I hope that you guys can help. Thanks.
Code isn't found, it is written.
mohitdeep_singh10:
I hope that you guys can help. Thanks.
We love to do exactly this!
You have a servo. I'll assume a hobby servo since you did not specify.
Wire up the servo per the sweep tutorial, upload the code and see if you can make it work.
Please note that the sweep tutorial powers the servo from the arduino 5v pin. This usually worls for one small unloaded servo but as soon as you try to make the servo do any real work, you pull more current that the 5v pin can provide and the board shuts down and reboots.
Better to be ahead of the game and use separate power supply for the servos. Google will help you if you need details on that.
If this does not work or you have any questions, ask here.
If you are going to post code, use code tags.
You have a weight sensor.
Remove the servo and wire up the sensor.
Many sensors have a library with examples. Load one up and print the sensor values to the serial monitor.
If no library, google the sensor name along with 'arduino' to see if anyone else has used that sensor.
If this does not work or you have any questions, ask here.
If you are going to post code, use code tags.
If you get this far, your next step is to combine the two pieces into one sketch.
If this does not work or you have any questions, ask here.
If you are going to post code, use code tags.
Good luck!
Use the forum search feature and search for "feeder".
I got only this far
this is slightly wrong, can you correct it?
#include <Servo.h>
//include Servo Library
Servo yourservo;
//add servo
int servoPin = 13;
int l_grams = 100; // grams you start
void setup()
{
yourservo.attach(servoPin);
//set servoPin(13) as an output
}
void loop()
{
void measurement_sensor ();
l_grams = value_from_wight_sensor; // use the wight meassurment sensor
int val = map (port, x, y, 0,1);
//This turn the value from the sensor (port) to the value (val) of 2 values, 1, and 0.
if (l_grams <= 50); //if the value is 0
{
yourservo.write(180); //turn the servo to 180ยบ
}
else if (l_grams >50); // if the value is 1
{
// do nothing or print / send a messsage
}
Hi mohitdeep_singh10,
to really help you we (the other forum-members) need more information.
Are you using a servo like they were used in radio-controlled cars, ships or airplanes?
if yes
Is your servo a servo that can do half a rotation back and forth ?
Or can your servo do continous rotation for multiple rotations
Can you explain how the mechanic of your feeder is working?
Does it need continous rotation or does it need a forward/backward movement?
The code you posted seems to be just a raw picture.
Can you provide a datasheet or any specs of your weight-measuring-sensor?
Do you have a ready to use code-library for that sensor?
If you expected to get this working by writing 30 lines of code in a manner like shouting at amazons Alexa "order a pizza from the next pizza-hut-store " I have to disappoint you. It is more work than that.
So another question: how much do you know about coding in general?
It is completely OK if you would answer "very little". It is just important for adapting answers to your knowledge-level.
best regards
Stefan
You have no definition of the function "measurement_sensor", or "port", "x" or "y"
An "if" should almost never be followed by a semicolon.
If you've tested something is <= some value, and it isn't, there is no need to test again to see if it is > than that value; a simple else will suffice.
There is a Pet Feeder Project in this link. Check if you can build it.
You can always ask questions in the Forum to get explanations on the working principles of some of the aspects of the Project.
Before you ask questions, you must divide the whole Project into suitable Modules in the way that suits you best and then start working on individual module and then combine them.
Each Module has specific hardware components and the associated software codes.
Remember that an example works as the best tutor in the journey of self learning.