Pet feeder scale with LCD1602 and 5buttons

Hi all =)

I'm new on this community, and i've a project ! :slight_smile:

I need your help.

My idea :

A pet feeder with a LCD1204 (ELEGOO), 5 buttons for menus, 4 weight sensor (style TEM01052B), a DC motor or steps per steps motor, an Archimède's screw.

For Wiring, i found solutions. But for the software... i'm a noob ^^

For menus :
If no buttons pressed => show time

-Manual meal
-Seeting => -Set time
-Set weight of meal
-Set time for Meal 1
-Set time for Meal 2

When the meal is given, the engine runs fast at first, and reduces speed towards the target weight.

Can you help me, please ? Thx =)

ps : sorry for my english, i'm french ^^

ps : sorry for my english, i'm french ^^

There is a French section of the forum, but, alas, no french section.

Your post is a bit like going to a pool, wearing cement boots and a trench coat, and wanting to learn how to use the diving board.

There are MANY areas of your (potential) project that can cause you issues. Reading the weight on the scale, for instance. Dispensing the right amount of food, as another example. Dispensing food at the right time will not be trivial.

Get one part at a time working. Leave the menu stuff until the very end.

Ok, thx for reply =)

How to do the schema? A page for each use?
Then, do you have any ideas for making this code?
thank you =)

Hi all =)
I created this code, and i need your opinions.
ps: do not consider number of pins.
This code compiling, but i need to reset meals gived each change of days. An idea ?

#include <DS3231.h>
#include <Stepper.h>
#include "HX711.h"
#include <LiquidCrystal.h>
#include <Wire.h> // needed for the RTC libraty
#include <Time.h>

DS3231 clocks;
RTCDateTime dt;

#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2
#define calibration_factor -7050.0
#define poids1 170 //poids de croquettes
#define vis 20 //nombre de steps
int feed1hour = 7;
int feed1minute = 00;
int feed2hour = 19;
int feed2minute = 00;

const int stepsPerRevolution = 64; //Steps par tours
Stepper myStepper(stepsPerRevolution, 2, 3, 4, 5); //Branchement moteur

const int pinBouton1 = 22; //Pin branchement bouton1
int buttonState = 0;
LiquidCrystal lcd(12, 11, 13, 8, 7, 6); //branchement écran
HX711 scale;
int pesee (scale.get_units());
int repasDonne = 0;

void setup() {
pinMode (pinBouton1, INPUT);
buttonState = digitalRead(pinBouton1);
lcd.begin(16, 2);
Serial.begin(9600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
clocks.begin();

}

void loop() {
if (buttonState == LOW){
static long virtualPosition=0; // without STATIC it does not count correctly!!!
dt = clocks.getDateTime();
lcd.setCursor(0, 0);
printDigits(dt.hour); //call to print digit function that adds leading zeros that may be missing
lcd.print(":");
printDigits(dt.minute);
lcd.print(":");
printDigits(dt.second);
lcd.print(" ");
lcd.setCursor(1,0);
lcd.print(repasDonne);
}
if ((timeFeed) && (manualFeed)){
feed();
}
}

void printDigits(int digits){ // utility function for digital display: prints leading 0
if(digits < 10)
lcd.print('0');
lcd.print(digits);
}
void feed(){

scale.tare();
if (pesee <= poids1){
lcd.setCursor(0,0);
lcd.print("poids =");
lcd.setCursor(0,1);
lcd.print(pesee);
myStepper.step(vis);
delay(500);
}
repasDonne ++;
}

void manualFeed(){

if (buttonState == HIGH) {
feed();

}
}

void timeFeed(){

if (dt.hour == feed1hour && dt.minute == feed1minute && dt.second == 0) {
feed();
}
if (dt.hour == feed2hour && dt.minute == feed2minute && dt.second == 0) {
feed();
}

}

and this code ?
I've include a 24h chrono for reset "repasDonne"

#include <DS3231.h>
#include <Stepper.h>
#include "HX711.h"
#include <LiquidCrystal.h>
#include <Wire.h> // needed for the RTC libraty
#include <Time.h>
#include <Chrono.h>

DS3231 clocks;
RTCDateTime dt;
Chrono myChrono;
#define LOADCELL_DOUT_PIN 3
#define LOADCELL_SCK_PIN 2
#define calibration_factor -7050.0
#define poids1 170 //poids de croquettes
#define vis 20 //nombre de steps
int feed1hour = 7;
int feed1minute = 00;
int feed2hour = 19;
int feed2minute = 00;

const int stepsPerRevolution = 64; //Steps par tours
Stepper myStepper(stepsPerRevolution, 2, 3, 4, 5); //Branchement moteur

const int pinBouton1 = 22; //Pin branchement bouton1
int buttonState = 0;
LiquidCrystal lcd(12, 11, 13, 8, 7, 6); //branchement écran
HX711 scale;
int pesee (scale.get_units());
int repasDonne = 0;

void setup() {
pinMode (pinBouton1, INPUT);
buttonState = digitalRead(pinBouton1);
lcd.begin(16, 2);
Serial.begin(9600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
clocks.begin();

}

void loop() {
if (buttonState == LOW){
static long virtualPosition=0; // without STATIC it does not count correctly!!!
dt = clocks.getDateTime();
lcd.setCursor(0, 0);
printDigits(dt.hour); //call to print digit function that adds leading zeros that may be missing
lcd.print(":");
printDigits(dt.minute);
lcd.print(":");
printDigits(dt.second);
lcd.print(" ");
lcd.setCursor(1,0);
lcd.print(repasDonne);
}
if ((timeFeed) && (manualFeed)){
feed();
}
if (myChrono.hasPassed(86400000)) {
repasDonne = 0;
}
}

void printDigits(int digits){ // utility function for digital display: prints leading 0
if(digits < 10)
lcd.print('0');
lcd.print(digits);
}
void feed(){

scale.tare();
if (pesee <= poids1){
lcd.setCursor(0,0);
lcd.print("poids =");
lcd.setCursor(0,1);
lcd.print(pesee);
myStepper.step(vis);
delay(500);
}
repasDonne ++;
}

void manualFeed(){

if (buttonState == HIGH) {
feed();

}
}

void timeFeed(){

if (dt.hour == feed1hour && dt.minute == feed1minute && dt.second == 0) {
feed();
}
if (dt.hour == feed2hour && dt.minute == feed2minute && dt.second == 0) {
feed();
}

}