Sad Cat Fixer Auto Feeder

by JensMann__ in Circuits > Arduino

261 Views, 0 Favorites, 0 Comments

Sad Cat Fixer Auto Feeder

dfa.jpg

For my Sad Cat Fixer Project, I made an auto feeder. This design will allow the owner of the cat to only have to put in a large amount of food in the top of the machine and they won't have to refill it or worry about their cat not being fed for a long time. This project uses a Servo motor, An LCD_i2c display, a real time clock (Rtc_Pcf8563), And an Arduino board.

3D Model

3D design Sad Cat Fixer 3d Model _ Tinkercad - Google Chrome 2022-01-21 8_35_42 AM.png
3D design Sad Cat Fixer 3d Model _ Tinkercad - Google Chrome 2022-01-21 8_35_33 AM.png

This is a 3d model of what the final project will look like when it is done.

Code

TinkercadCode1.png
TinkercadCode2.png
TinkercadCode3.png
TinkercadCode4.png

#include // for I2C communication
#include // for LCD #include // for RTC #include // Servo Library #define PCF8563address 0x51

LiquidCrystal_I2C lcd(0x27, 16, 2); // create LCD with I2C address 0x27, 16 characters per line, 2 lines Rtc_Pcf8563 rtc; // create rtc for the DS3231 RTC module, address is fixed at 0x68

/* function to update RTC time using user input */

void setup() { Serial.begin(9600); // initialize serial

lcd.init(); // initialize lcd lcd.backlight(); // switch-on lcd backlight

rtc.initClock(); // initialize rtc //day, weekday, month, century, year rtc.setDate(19, 3, 1, 20, 22); //hr, min, sec; rtc.setTime (8, 30, 30); }

void loop() { updateLCD(); // update LCD text

if (Serial.available()) { char input = Serial.read(); if (input == 'u') updateRTC(); // update RTC time } }

void updateRTC() {

lcd.setCursor(0, 0); lcd.print("Time:"); lcd.setCursor(6, 0); //lcd.print(rtc.formatTime(RTCC_TIME_HM)); lcd.print(rtc.formatTime());

lcd.setCursor(0, 1); lcd.print("Date:"); lcd.setCursor(6, 1); //lcd.print(rtc.formatDate(RTCC_DATE_ASIA)); lcd.print(rtc.formatDate());

// ask user to enter new date and time const char txt[6][15] = { "year [4-digit]", "month [1~12]", "day [1~31]", "hours [0~23]", "minutes [0~59]", "seconds [0~59]"

}; String str = ""; long newDate[6];

while (Serial.available()) { Serial.read(); // clear serial buffer }

for (int i = 0; i < 6; i++) {

Serial.print("Enter "); Serial.print(txt[i]); Serial.print(": ");

while (!Serial.available()) { ; // wait for user input }

str = Serial.readString(); // read user input newDate[i] = str.toInt(); // convert user input to number and save to array

Serial.println(newDate[i]); // show user input } }

/* function to update LCD text */ void updateLCD() {

/* create array to convert digit days to words:

0 = Sunday | 4 = Thursday 1 = Monday | 5 = Friday 2 = Tuesday | 6 = Saturday 3 = Wednesday | */ const char dayInWords[7][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

/* create array to convert digit months to words:

0 = [no use] | 1 = January | 6 = June 2 = February | 7 = July 3 = March | 8 = August 4 = April | 9 = September 5 = May | 10 = October 6 = June | 11 = November 7 = July | 12 = December */

const char monthInWords[13][4] = {" ", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };

// get time and date from RTC and save in variables DateTime rtcTime = rtc.now();

int ss = rtcTime.second(); int mm = rtcTime.minute(); int hh = rtcTime.twelveHour(); int DD = rtcTime.dayOfTheWeek(); int dd = rtcTime.day(); int MM = rtcTime.month(); int yyyy = rtcTime.year();

// move LCD cursor to upper-left position lcd.setCursor(0, 0);

// print date in dd-MMM-yyyy format and day of week if (dd < 10) lcd.print("0"); // add preceeding '0' if number is less than 10 lcd.print(dd); lcd.print("-"); lcd.print(monthInWords[MM]); lcd.print("-"); lcd.print(yyyy);

lcd.print(" "); lcd.print(dayInWords[DD]);

// move LCD cursor to lower-left position lcd.setCursor(0, 1);

// print time in 12H format if (hh < 10) lcd.print("0"); lcd.print(hh); lcd.print(':');

if (mm < 10) lcd.print("0"); lcd.print(mm); lcd.print(':');

if (ss < 10) lcd.print("0"); lcd.print(ss);

if (rtcTime.isPM()) lcd.print(" PM"); // print AM/PM indication else lcd.print(" AM"); }

void Alarm(); { /* set an alarm for 3 hours later... * alarm pin goes low when match occurs * this triggers the interrupt routine * min, hr, day, weekday * 99 = no alarm value to be set */ rtc.setAlarm(99, 3, 99, 99); /* each sec update the display */ Serial.print(rtc.formatTime()); Serial.print(" "); Serial.print(rtc.formatDate()); Serial.print(" 0x");

Serial.print(rtc.getStatus2(), HEX); Serial.print("\r\n"); delay(1000); if (alarm_flag==1){ clr_alarm();

}

Circuit Diagram

IMG-6116.JPG

Physical Build (Early Version)

Early version of my physical build

Downloads