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

/media/uploads/jeremycai3721/setup.jpg

/media/uploads/jeremycai3721/connection_XmED10e.jpg

Wiring for Class-D Amplifier

mbedTPA2005D1Speaker
gndpwr - (gnd), in -
Vout (3.3V) or 5Vpwr +
p26 (any PWM or D/A)in +
out ++
out --
Any DigitalOut px(optional)S (low for shutdown)

Wiring for MicroSD Card

MicroSDmbed
CS8
DI5
VCCVOUT
SCK7
GNDGND
DO6
CD

Wiring for Adafruit Bluefruit BLE

mbed Adafruit BLE
gndgnd
VU(5v)Vin
ncRTS
GndCTS
p27 (Serial RX)TXO
p28 (Serial TX)RXI

Wiring for Servo

mbedservoexternal DC supply
gndgnd (black)gnd
power (red)+4.8V to 6V
p21 or any PWMPWM 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

/media/uploads/jeremycai3721/rcservo.jpg /media/uploads/jeremycai3721/servowiring.png /media/uploads/jeremycai3721/servo.jpg /media/uploads/jeremycai3721/powersupply.jpg /media/uploads/jeremycai3721/powerjack.jpg

Bluetooth Control

/media/uploads/jeremycai3721/ble.jpg

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.

/media/uploads/jeremycai3721/command1.png /media/uploads/jeremycai3721/command2.png

Demo Video


Please log in to post comments.