This shows you the differences between two versions of the page.
pm:prj2025:eradu:andra.belceanu [2025/05/19 11:18] andra.belceanu [Introduction] |
pm:prj2025:eradu:andra.belceanu [2025/05/29 23:35] (current) andra.belceanu [Software Design] |
||
---|---|---|---|
Line 121: | Line 121: | ||
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. | 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 ====== | + | {{: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|}} | ||
- | **Development Environment:** | + | ===== Software Design ===== |
- | 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 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> | ||
- | **Libraries and 3rd-Party Sources Used:** | + | **Software Status** |
- | ^ Library Name ^ Purpose ^ | + | The firmware is complete and tested on Arduino Uno. It handles: |
- | | FastLED.h | Controls WS2812 RGB LED matrices with high-performance animations | | + | |
- | | Adafruit_NeoPixel.h | Alternative library for driving NeoPixel (WS2812) LEDs | | + | |
- | | Servo.h | Controls the servo motor responsible for food dispensing | | + | |
- | | EEPROM.h | Store configuration or last feeding timestamp | | + | |
- | | TimerOne.h | Enables time-based control for feeding intervals | | + | |
- | **Algorithms and Planned Structures:** | + | * 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) | ||
- | The firmware is structured into two main parts: | + | All features were validated using serial monitoring, visual LED feedback, and servo actuation tests. |
- | * **1. LED Animation Control** | + | **Libraries Used and Purpose** |
- | - Handles 3 predefined animations using FastLED (`snake`, `vortex`, `int_ext`). | + | |
- | - A **button** is used to switch between animation modes (via external interrupt). | + | |
- | - A **potentiometer** adjusts the color of animations in real-time. | + | |
- | * **2. Cat Feeder Logic (to be implemented in Stage 3)** | + | ^ Library Name ^ Purpose ^ |
- | - Uses a **proximity sensor** to detect the presence of the cat. | + | | FastLED.h | Controls WS2812 RGB LED matrices with fast and flexible animations | |
- | - When the cat is present and enough time has passed since the last feeding: | + | | Servo.h | Controls the food-dispensing servo via PWM (pin D5) | |
- | - A **servo motor** rotates to release food. | + | | TimeLib.h | Simulates a clock to check scheduled feeding times | |
- | - A light animation or color feedback is shown to indicate successful feeding. | + | | Adafruit_NeoPixel.h | Used initially for LED testing; replaced later by FastLED | |
- | ==== Sources and Implemented Functions ==== | + | **Key Innovation** |
- | ^ 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 | | + | |
+ | 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. | ||
- | ==== Conclusion ==== |