03/02/2025 UPDATE!!!


----------------------------------------------------------------------------------------------------------------
The CHONK is essentially an automated system that dispenses food when your pet comes close enough. The ultrasonic sensor detects the presence of your pet, and the servo motor controls the dispensing mechanism based on the proximity and timing logic in the code.
Hardware:
Software:


Ultrasonic Sensor:
Servo Motor:
I tried to keep the code as simple as possible. This is the link to the site from which I downloaded the initial code: https://wokwi.com, but I improved it a bit with AI to make it more suitable for the purpose.
The code uses an ESP32 microcontroller to control a servo motor based on distance measurements from an ultrasonic sensor. When an object is detected within a specified distance threshold, the servo motor rotates to a certain angle, simulating the opening and closing of a door. The servo motor only opens the door when an object is detected within the specified distance, and there is a delay between subsequent activations to avoid continuous triggering.
#include <ESP32Servo.h>
#define TRIG_PIN 23 // ESP32 pin GPIO23 connected to Ultrasonic Sensor's TRIG pin
#define ECHO_PIN 22 // ESP32 pin GPIO22 connected to Ultrasonic Sensor's ECHO pin
#define SERVO_PIN 26 // ESP32 pin GPIO26 connected to Servo Motor's pin
#define DISTANCE_THRESHOLD 10 // Distance threshold in centimeters
Servo servo; // Create servo object to control the servo motor
// Variables for distance measurement and timing
float duration_us, distance_cm;
unsigned long lastActivatedTime = 0;
unsigned long delayPeriod = 10000; // Delay period of 10 seconds in milliseconds
void setup() {
Serial.begin(9600); // Initialize serial port
pinMode(TRIG_PIN, OUTPUT); // Set ESP32 pin as output for TRIG pin
pinMode(ECHO_PIN, INPUT); // Set ESP32 pin as input for ECHO pin
servo.attach(SERVO_PIN); // Attach the servo to pin 26
servo.write(0); // Initialize servo position to 0 degrees (closed door)
}
void loop() {
// Generate 10-microsecond pulse to TRIG pin
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Measure duration of pulse from ECHO pin
duration_us = pulseIn(ECHO_PIN, HIGH);
// Calculate the distance in centimeters
distance_cm = 0.017 * duration_us;
unsigned long currentTime = millis();
// Check if the distance is below the threshold and the delay period has passed
if (distance_cm < DISTANCE_THRESHOLD && currentTime - lastActivatedTime >= delayPeriod) {
servo.write(90); // Rotate servo motor to 90 degrees (open door)
delay(1000); // Keep the door open for 1 second
servo.write(0); // Close the door
lastActivatedTime = currentTime; // Update the last activation time
}
// Print the measured distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(500); // Wait for 500 milliseconds before taking another measurement
}
All the printable parts files are already correctly oriented for convenient printing in STEP, STL & 3DM files with consideration for minimum supports.
1. Mechanism enclosure (bottom part): Supports are required in the marked areas below.


2. Food hopper (top part): Supports are required in the marked areas below.
![]()
![]()
3. Lid (for the food hopper): Supports are required in the marked areas below.


4. Shaft Updated 03/02/2025 (the part was updated bet the printing Instructions are still the same) (goes inside the Mechanism enclosure & connects to the MG90 servo motor with M2 screw): Supports are required (automatic).


5. Slot plug (two pcs required): Holds the Shaft in the Mechanism enclosure. No supports are required. (After an initial test, overall, it seems that the feeder works even without these parts.)



Follow up for the updates & the upcoming photos of the print!
Let me know what you think in the comments! Happy printing!
The author marked this model as their own original creation.