PurrGlow Feeder

Name: Andra-Maria Belceanu
Group: 331CA

Introduction

PurrGlow Feeder is a smart, automatic cat feeder that dispenses food at four fixed times per day. Additionally, an extra portion can be triggered manually when the owner holds their hand near the proximity sensor for at least two seconds. The system uses a servo motor to rotate a food container and release food into the bowl. The main goal of the project is to automate and optimize the cat feeding process, reducing waste and ensuring the pet eats at regular intervals. The idea came from a personal need to reliably feed a cat even when not at home, while also making the experience more interactive. A colorful LED cube acts as a night light and plays dynamic light patterns whenever food is served. One of the lighting modes can be customized using a potentiometer, giving the owner some control over the ambience. A button is also used to change the light modes, implemented using an external interrupt. This project is useful for pet owners who want an efficient and engaging way to care for their animals, and for us, it’s a fun and educational way to apply embedded systems concepts to a real-world scenario.

General Description

The PurrGlow Feeder system automates the cat feeding process and adds visual interaction through an LED cube. It includes scheduled feeding at four fixed times during the day, and the owner can manually trigger extra feeding by holding a hand near a proximity sensor for 2 seconds. The system is built around an Arduino Uno microcontroller, which controls all components and logic.

Hardware Modules:

  • Arduino Uno – central unit managing timing, sensor input, servo control, and LED animations.
  • Proximity Sensor – detects the owner's hand for 2 seconds to trigger an extra feeding portion.
  • Servo Motor – dispenses food by rotating a container flap, controlled via PWM (D5).
  • LED Cube (5x WS2812B matrices) – displays lighting animations when food is dispensed or on user interaction.
  • Button – allows switching between predefined light modes; connected to digital pin D2 using external interrupt.
  • Potentiometer – adjusts animation color or speed; connected to analog input A0.

Software Modules:

  • Timer Logic – checks whether the current time matches any of the four scheduled meal times.
  • Feeding Control – activates the servo at scheduled times or when proximity input exceeds 2 seconds.
  • LED Animation Controller – handles light patterns and responds to button/potentiometer input.
  • Interrupt Handler – reacts to button presses to change light modes in real-time.

Interaction Flow:

  • Food is automatically dispensed at 08:00, 12:00, 18:00, and 22:00.
  • An extra portion can be given by holding a hand near the sensor for at least 2 seconds.
  • A green LED animation confirms that food has been released.
  • The user can:
    • Press the button to switch LED modes.
    • Use the potentiometer to customize the color of one mode.

All logic is handled by the Arduino in real time using digital, analog, PWM, and interrupt-based inputs.

Hardware Design

List of Components:

  • 1x Arduino Uno
  • 1x Proximity Sensor
  • 1x Servo Motor (for food dispenser)
  • 5x LED Matrices (4×4 WS2812B)
  • 1x Potentiometer
  • 1x Push Button
  • Resistors
  • Connecting wires
  • Breadboard
  • Wires

Connection Overview:

  • The servo motor is controlled via a PWM pin.
  • LED matrices are chained and connected to a single digital output.
  • The push button is connected via a digital input with external interrupt support.
  • The potentiometer is read via an analog input pin.
  • The proximity sensor sends a digital signal to the Arduino.

Overview on hardware:

The hardware design of the PurrGlow Feeder includes several modules integrated around an Arduino Uno board, enabling both scheduled and on-demand food dispensing with visual feedback.

Arduino Uno

Acts as the main controller. It keeps time, handles feeding logic, controls the servo, reads sensor and input data, and manages LED animations. All components are powered from the Arduino’s 5V supply line.

Servo Motor (SG90)

Controlled via PWM on digital pin D5, the servo rotates to release food. It activates automatically at four fixed times per day.

Proximity Sensor (HC-SR04)

Connected to pins D3 (TRIG) and D4 (ECHO), this sensor is used by the owner to manually trigger extra feeding. If it detects presence continuously for 2 seconds, a food portion is released. The module runs at 5V and uses about 15 mA.

LED Cube (5× WS2812B matrices)

All matrices are daisy-chained and driven from pin D7 using FastLED. They display predefined lighting animations during feeding. Brightness is limited in software to reduce power usage (total draw ≈ 200 mA).

Push Button (mode switch)

Connected to pin D2 via an external interrupt, this button lets the user switch between different LED animation modes at any time.

Potentiometer

Wired to analog pin A0, the potentiometer allows the user to adjust either the LED animation speed or the color in specific modes.

The system is designed for simplicity and low power consumption, drawing under 500 mA total. Feeding can happen automatically or on request, and all interactions are confirmed visually via the LED cube.

Pin Usage

Each hardware component is mapped to specific pins on the Arduino Uno, chosen based on electrical compatibility, timing requirements, or interrupt support.

D2 – Push Button (INT0)

This pin is used because it supports external interrupts (INT0 / PCINT18). It allows the system to detect button presses asynchronously and switch LED animation modes instantly.

D3 – HC-SR04 TRIG

Configured as a digital output to send ultrasonic pulses. It was chosen as a general-purpose pin close to D4, forming a logical pair for the proximity sensor.

D4 – HC-SR04 ECHO

Configured as a digital input to receive the echo signal. It is read using `pulseIn()` to measure distance accurately.

D5 – Servo Motor PWM

This pin supports hardware PWM and is connected to the SG90 servo. It allows precise pulse-width modulation for angle control during feeding.

D7 – LED Cube Data In

Used as the data pin for the WS2812B LED matrices. Chosen for its ability to handle tight 800 kHz timing required by FastLED, and because it's not shared with any serial or I²C functions.

A0 – Potentiometer

This analog input reads voltage from the potentiometer to control either LED speed or color. A0 is conventionally used for analog input and provides stable readings.

All components share a common GND, and are powered from the Arduino’s 5V rail. Pin assignments were selected to minimize conflict with internal timers and preserve clean signal timing for both the servo and WS2812 LEDs.

Software Design

This section documents the current state of the software implementation for the PurrGlow Feeder project, including development decisions, feature validation, and sensor calibration. The firmware was developed using the Arduino IDE, chosen for its simplicity and built-in support for common microcontroller platforms such as Arduino Uno. The environment supports both code compilation and serial monitoring.

Software Status

The firmware is complete and tested on Arduino Uno. It handles:

  • Automatic food dispensing at four fixed simulated hours (08:00, 12:00, 18:00, 22:00)
  • Manual food dispensing by holding a hand near the proximity sensor for 2 seconds
  • Dynamic LED animations triggered after food events
  • Interaction via external interrupt (button) and analog input (potentiometer)

All features were validated using serial monitoring, visual LED feedback, and servo actuation tests.

Libraries Used and Purpose

Library Name Purpose
FastLED.h Controls WS2812 RGB LED matrices with fast and flexible animations
Servo.h Controls the food-dispensing servo via PWM (pin D5)
TimeLib.h Simulates a clock to check scheduled feeding times
Adafruit_NeoPixel.h Used initially for LED testing; replaced later by FastLED

Key Innovation

This project adds novelty through:

  • Manual override for feeding via proximity detection by the owner
  • Real-time interactive LED cube (5 WS2812B faces) with dynamic effects
  • Color control in one of the modes via a potentiometer and mode switching with a button interrupt

Use of Lab Functionality

We reused and extended concepts from the labs:

  • Lab 0 (GPIO) – Used for ultrasonic trigger/echo, servo control, LED signal, and button input
  • Lab 2 (Interrupts) – External interrupt on D2 allows seamless light mode switching via button
  • Lab 3 (Timere, PWM) – Servo is controlled via Servo.h, which uses PWM on pin D5
  • Lab 4 (ADC) – The potentiometer is read as analog input to control LED speed or color

Project Architecture

  • Feeding Logic
    • feedHours[] holds the daily schedule
    • alreadyFed[4] prevents multiple activations in the same slot
    • checkManualFeeding() uses ultrasonic sensor to detect stable presence for 2 seconds
  • Animations
    • 11 visual effects switch every 10 seconds after feeding (effectCycles)
    • game variable cycles through effects
    • fade_color() mode allows full color transition via potentiometer
  • Interaction
    • External button on D2 (interrupt) cycles animation modes
    • Potentiometer on A0 adjusts animation speed or color

Sensor Calibration

  • Distance threshold: Set at 15 cm for manual activation
  • Stability check: Presence must be detected continuously for 2 seconds
  • Noise filter: Brief readings under 300 ms are ignored

Sources and Implemented Functions

Function / Module Description
snake() Snake effect moving across the LED matrix
vortex() Circular animation effect across all matrices
fade_color() Smooth color transition based on potentiometer position
random_star() Randomly lights up LEDs like a starry sky
convert_speed() Converts potentiometer analog value to animation speed
poweroff() Turns off all LEDs
readDistanceCM() Measures distance with ultrasonic sensor
rotateServo() Controls the servo motor to dispense food via PWM (D5)
checkManualFeeding() Detects hand presence for 2s and triggers extra feeding
checkScheduledFeeding() Dispenses food based on simulated time and schedule

Demo Video Video link: https://youtube.com/shorts/k56aoU-vjDw?feature=share

The video shows:

  • Scheduled and manual food dispensing
  • Real-time LED feedback
  • Button-based animation switching
  • Color/speed tuning with potentiometer

Source code: https://github.com/AndraBel/PurrGlow-Feeder/tree/main

Conclusion

Working on the PurrGlow Feeder project has been a very interesting and rewarding experience. I spent a lot of time and effort especially on assembling the LED cube, combining five separate matrices into a clean, functional structure was far more difficult than expected. The feeder system itself also posed its own challenges, particularly in calibrating the servo movement and integrating it with the sensor logic. Even though it took a good amount of trial and error, I'm proud that both the animation system and the food dispensing logic now work. The whole project came together nicely, and seeing it function in real life made all the effort worthwhile.

pm/prj2025/eradu/andra.belceanu.txt · Last modified: 2025/05/29 23:35 by andra.belceanu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0