Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2025:eradu:andra.belceanu [2025/05/19 10:45]
andra.belceanu [Detailed Hardware Functionality]
pm:prj2025:eradu:andra.belceanu [2025/05/29 23:35] (current)
andra.belceanu [Software Design]
Line 9: Line 9:
  
  
-**PurrGlow Feeder** is a smart, automatic cat feeder that dispenses food at four fixed times per day, but only when the cat is nearbyIt uses a proximity sensor to detect the cat’s presence and activates a motor to rotate a food container, releasing ​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.+**PurrGlow Feeder** is a smart, automatic cat feeder that dispenses food at four fixed times per day. Additionallyan extra portion can be triggered manually ​when the owner holds their hand near the proximity sensor for at least two secondsThe 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 ===== ===== General Description =====
  
-The **PurrGlow Feeder** system ​includes both hardware and software modules that work together to automate ​cat feeding and provide interactive feedback ​through an LED cube. Below is an overview of the main modules ​and how they interact:+<note tip> 
 +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. 
 +</​note>​
  
-**Hardware Modules** +**Hardware Modules:**
-  * **Arduino Microcontroller** – the central unit that handles all logic and communication between components. +
-  * **Proximity Sensor** – detects when the cat is near the bowl and sends a digital input signal to the Arduino. +
-  * **Servo Motor** – controlled via PWM by the Arduino to rotate and release food from the container. +
-  * **LED Cube (5 LED Matrices)** – displays lighting animations when food is dispensed or when switched by the user. +
-  * **Button** – used to switch between predefined light modes; connected via an external interrupt. +
-  * **Potentiometer** – allows the owner to manually adjust the color or brightness of a customizable LED mode; read as analog input.+
  
-**Software Modules** +   * **Arduino Uno** – central unit managing timing, sensor input, servo control, and LED animations. 
-  * **Timer Logic** – manages ​the four fixed feeding ​times per day (e.g., 08:00, 12:00, 18:00, 22:00)+   * **Proximity Sensor** – detects the owner'​s hand for 2 seconds to trigger an extra feeding portion. 
-  * **Feeding Control** – decides whether to activate ​the servo motor based on time and proximity input. +   * **Servo Motor** – dispenses food by rotating a container flap, controlled via PWM (D5). 
-  * **Animation Controller** – controls the LED cube effects based on the button ​and potentiometer ​values+   * **LED Cube (5x WS2812B matrices)** – displays lighting animations when food is dispensed or on user interaction. 
-  * **Interrupt Handler** – triggered ​by the button to switch LED modes smoothly.+   * **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.
  
-**Interaction Flow** 
-  * The timer checks whether the current time matches a scheduled meal time. 
-  * If the time matches and the cat is detected nearby, the servo motor is activated to dispense food. 
-  * Simultaneously,​ the LED cube plays an animation. 
-  * The user can: 
-    * Press the button to cycle through animation modes. 
-    * Adjust the potentiometer to customize the color of one mode. 
-  * All logic is managed by the Arduino in real time using digital, analog, and interrupt inputs. 
  
 {{:​pm:​prj2025:​eradu:​diag2bun.png?​600x300|}} {{:​pm:​prj2025:​eradu:​diag2bun.png?​600x300|}}
Line 63: Line 70:
   * The proximity sensor sends a digital signal to the Arduino.   * The proximity sensor sends a digital signal to the Arduino.
  
-===== Detailed Hardware Functionality =====+**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. 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.
Line 90: Line 97:
 {{:​pm:​prj2025:​eradu:​whatsapp_image_2025-05-11_at_22.03.29.jpeg?​800x450|}} {{:​pm:​prj2025:​eradu:​whatsapp_image_2025-05-11_at_22.03.29.jpeg?​800x450|}}
  
-====== Software Design ======+===== 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. 
 + 
 +{{:​pm:​prj2025:​eradu:​whatsapp_image_2025-05-21_at_18.27.41_2_.jpeg?​200|}} 
 +{{:​pm:​prj2025:​eradu:​whatsapp_image_2025-05-21_at_18.27.41.jpeg?​200|}} 
 +{{:​pm:​prj2025:​eradu:​whatsapp_image_2025-05-21_at_18.27.41_1_.jpeg?​200|}} 
 +{{:​pm:​prj2025:​eradu:​whatsapp_image_2025-05-21_at_18.27.41_3_.jpeg?​200|}} 
 +{{:​pm:​prj2025:​eradu:​whatsapp_image_2025-05-21_at_18.27.41_5_.jpeg?​200|}} 
 + 
 +===== Software Design ===== 
 + 
 +<note important> ​  
 +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. ​  
 +</​note>​ 
 + 
 +**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**
  
-**Development Environment:**+ Distance threshold: Set at 15 cm for manual activation 
 + Stability checkPresence must be detected continuously for 2 seconds 
 + Noise filter: Brief readings under 300 ms are ignored
  
-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. 
  
-**Libraries and 3rd-Party ​Sources ​Used:**+**Sources ​and Implemented Functions**
  
-Library Name           Purpose ​                                                                +Function / Module ​       ​Description ​                                                           ​  
-FastLED.h ​             ​Controls WS2812 RGB LED matrices ​with high-performance animations ​       ​+snake() ​                Snake effect moving across the LED matrix ​                             |   
-Adafruit_NeoPixel.h ​   ​Alternative library for driving NeoPixel ​(WS2812) LEDs                   ​+| vortex() ​               | Circular animation effect across all matrices ​                           
-Servo.h ​               ​| Controls the servo motor responsible for food dispensing ​    +fade_color() ​           ​Smooth color transition based on potentiometer position ​               |   
-EEPROM.h ​              Store configuration or last feeding ​timestamp ​                 ​+| random_star()           | Randomly lights up LEDs like a starry sky                              ​  
-TimerOne.h ​            Enables time-based control for feeding intervals ​              |+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 ​                   ​|
  
-**Algorithms and Planned Structures:**+**Demo Video** 
 +Video link: https://​youtube.com/​shorts/​k56aoU-vjDw?​feature=share
  
-The firmware is structured into two main parts:+The video shows:
  
-  ​* **1. LED Animation Control*+ Scheduled and manual food dispensing 
-    ​Handles 3 predefined animations using FastLED (`snake`, `vortex`, `int_ext`). + Real-time ​LED feedback 
-    - A **button** is used to switch between ​animation ​modes (via external interrupt). + Button-based animation ​switching 
-    - A **potentiometer** adjusts the color of animations in real-time.+Color/speed tuning with potentiometer
  
-  * **2. Cat Feeder Logic (to be implemented in Stage 3)** +Source codehttps://​github.com/​AndraBel/​PurrGlow-Feeder/​tree/​main
-    - Uses a **proximity sensor** to detect the presence of the cat. +
-    - When the cat is present and enough time has passed since the last feeding: +
-        - A **servo motor** rotates to release food. +
-        ​A light animation or color feedback is shown to indicate successful feeding.+
  
-==== 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                                                             | 
-| detectPresence() ​     | Measures distance with ultrasonic sensor to detect the cat                     | 
-| rotateServo() ​        | Controls the servo motor to dispense food                                      | 
-| shouldFeedNow() ​      | Checks if it is the correct time to feed                                       | 
  
 +===== 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.
  
-==== Conclusion ==== 
pm/prj2025/eradu/andra.belceanu.1747640722.txt.gz · Last modified: 2025/05/19 10:45 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