Cat Food Dispenser
Introduction
This project is a simple food dispenser at home for your cats. It allows your to remotely control the feeding process on a mobile device using Bluetooth connection. You are also able to play music through the speaker after dispensing the food.
Components and Peripherals
- mbed
- Class-D Amplifier
- Speaker
- Resistor pot (for volume control)
- MicroSD card
- Adafruit Bluefruit BLE
- 5VDC 2A AC wall adapter
- Barrel jack
- RC Servo
Wiring for Class-D Amplifier
mbed | TPA2005D1 | Speaker |
gnd | pwr - (gnd), in - | |
Vout (3.3V) or 5V | pwr + | |
p26 (any PWM or D/A) | in + | |
out + | + | |
out - | - | |
Any DigitalOut px(optional) | S (low for shutdown) |
Wiring for MicroSD Card
MicroSD | mbed |
CS | 8 |
DI | 5 |
VCC | VOUT |
SCK | 7 |
GND | GND |
DO | 6 |
CD |
Wiring for Adafruit Bluefruit BLE
mbed | Adafruit BLE |
gnd | gnd |
VU(5v) | Vin |
nc | RTS |
Gnd | CTS |
p27 (Serial RX) | TXO |
p28 (Serial TX) | RXI |
Wiring for Servo
mbed | servo | external DC supply |
gnd | gnd (black) | gnd |
power (red) | +4.8V to 6V | |
p21 or any PWM | PWM signal input (white, yellow, orange) |
Program
Import programCatFoodDispenser
Cat food dispenser demo.
Code Snippets
#include "mbed.h" #include "Servo.h" #include "SDFileSystem.h" #include "wave_player.h" // SD card SDFileSystem sd(p5, p6, p7, p8, "sd"); // Waveplayer AnalogOut DACout(p18); wave_player waver(&DACout); // Bluetooth Serial blue(p28,p27); // Servo Servo myservo(p21); int main() { // Adjust servo to default position myservo = 0.0; while(1) { // Check whether user is sending "feed" through bluetooth if (blue.getc()=='f') { if (blue.getc()=='e') { if (blue.getc()=='e') { if (blue.getc()=='d') { // After receiving "feed", start dispensing cat food myservo = 0.7; wait(1); myservo = 0.0; wait(0.5); {{/media/uploads/jeremycai3721/servowiring.png}} // Play wav file on SD FILE *wave_file; wave_file=fopen("/sd/food.wav","r"); waver.play(wave_file); fclose(wave_file); } } } } } }
Servo Setup
Bluetooth Control
Here are the steps for remote control setup:
Make sure that the mini slide switch on Adafruit board set to "UART" (not "CMD")
Download "Adafruit Bluefruit BLE" App for your iOS or Android phone or tablet in the Apple App or Google Play store. This app provides an easy to use interface for Bluetooth connection and command sending.
In the UART section, type in "feed" and press "send". The program running on mbed will check the command and start to dispense food and play music.
Demo Video
Please log in to post comments.