Introduction: Tweeting Dog Feeder

So I wanted to create a dog feeder that sends an update to Twitter whenever the feeder is opened. My brother, my sister, and I each take care of my cousin's dog (Milo) since his job doesn't allow him enough time to check on him through out the day. We have always had to keep tabs on one another to make sure Milo has been fed and taken out for that day. This dog feeder is a way that eliminates us having to text or call one another to see if Milo has been checked up on by having a Twitter account that we can each access and check for Milo's status to update. This also lets my cousin know when we have fed and walked Milo. This also provides a means for accountability.

In short, I used an Arduino with an Arduino Ethernet Shield and a tilt switch that updates Twitter each time the lid is opened.

Step 1: Step 1: What You Will Need

First off, I would like to say that you can use whatever means you would like to execute this project to make it look more professional. I will be walking you through the steps of my execution by using whatever I had lying around the house.

- Arduino Uno
- Arduino Ethernet Shield (
- Tilt Switch - part number 107 - 2007 - EV (
- Ethernet Cable 6 Cat. (Best Buy)
- Wire ( 19 gauge)
- Shrink Tube
- A 10 Kohm resistor (Radio Shack)
- Sticky-Sided Velcro (Walmart)
- Small Zip Ties
- Tuber ware Containers
- A 1"x1" block of wood
- Super Glue
- Staple Gun w/staples
- A Window Shim

Step 2: Step 2: Understanding the Tilt Switch

The tilt switch works just like a push-button switch except instead of pushing a button, obviously, it tilts to close the circuit. This tilt switch in particular closes it's circuit after a 30 degree tilt. As long as it stays tilted passed 30 degrees, it will stay on. I will incorporate this tilt switch to my Arduino board so what when I open the lid of the feeder, it will tell the Arduino to update Twitter. For now, here is a video showing how it turns on the built-in LED light on my Arduino.

Step 3: Step 3: Getting the Code

This is the step where we program our Arduino to send update tweets to Twitter.

But first things first:

At this point we’ll need some additional libraries. Download the Twitter Library and add it to your libraries folder within your Arduino IDE (Mac: Documents › Arduino › libraries or respectively on Windows: My Documents › Arduino › libraries). You will also need to down load True Random Library the same way.

*Twitter Library can be found at:
*True Random Library can be found at:

After that import (Arduino › Sketch › Import Library…) the following libraries to your current sketch: SPI, Ethernet, Twitter, TrueRandom.

Here is the code:

#include<SPI.h> // needed in Arduino 0019 or later

// Ethernet Settings
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // No need to change the default Mac address
byte ip[] = { 123, 456, 78, 90 }; // Insert your Ethernet IP

// This is where you can write your own tweets. Just make sure the %d stays in front of the comments and
//you separate each one with a comma.
const char* miloQuotes[] = {“%d: Oh boy!! Someone’s here!!” , “%d: Hurray!! Starvation is OVER!” , “%d: SQUIRREL!!” , “%d: Hello world!”,
“%d: Is it just me or is it time to go outside?” , “%d: My shephard has arrived.” , “%d: Dogs don’t say woof... smh.” , “%d: I heard a noise!!” , “%d: I sure would love a bone right now...” };

// OAuth Token
// Get your Token here:
Twitter twitter(“123456789-abcdefghijklmnopqrstuvwxyz”);
// When you follow the above link and get your Twitter token, put it inside the parenthesis. This will link your Arduino with your Twitter account.

// Counter
// This is the number that will appear in front of each of your Tweets that will count each tweet.
//This is necessary so that Twitter does not reject your tweet if it happens to be a duplicate.
int i=0; // start with zero
char buf[100];

// Pin
int buttonPin = 9; // Pin for the Tilt Switch

void setup() {
pinMode(buttonPin, INPUT);

// This block of code tells your Arduino to Tweet
void tweet(char msg[]) {
Serial.println(“connecting ...”);
if ( {
int status = twitter.wait(&Serial);
if (status == 200) {
else {
Serial.print(“failed : code “);
else {
Serial.println(“connection failed.”);

// This block of code allows your Arduino to continually search for the switch to be turned on.
void loop() {
if (digitalRead(buttonPin) == HIGH) {
// convert everything to string(char)
sprintf(buf, miloQuotes[TrueRandom.random(9)] , i); // This selects your messages at random.
// delay

Step 4: Step 4: Wiring Your Arduino

When wiring my Arduino, I connected one of the wires to the 5volt pin, and connect a 10 Kohm resistor to pin 9 and also the ground. From there, I soldered a wire to the 10 Kohm resistor. Both of these wires will be soldered to the tilt switch.

In this step I also attached my Arduino Uno and Ethernet Shield to a window shim with a zip tie. I did this so that when I use the sticky sided velcro, It will stick to the shim and not the Arduino. The velcro will be covered in a later step with pictures showing how it was used.

Step 5: Step 5: Connecting the Arduino to the Feeder

In this step I have connected the Arduino Uno with Ethernet Shield to the back of Milo's feeder with some velcro. I then covered the Arduino with a clear tuber ware container. Here is how I did so:

First, like I mentioned in the last step, I have attached my Arduino to the window shim with a zip tie. From there, I attached the sticky sided velcro to the back side of the window shim, and attached the other side of the velcro to the spot on the feeder that I wanted it to go.

After I had done this, I put a household tuber ware container over the Arduino to protect it from Milo's curiosity, as well as any one who happens to bump it or knock the feeder over. To do this, I first cut out a hole in the tuber ware container to allow the wires and the ethernet cable to pass through. I then attached more sticky sided velcro on the bottom of the tuber ware, as well as the corresponding side of the feeder that the tuber ware will be attached to.

Step 6: Step 6: Assembling/Attaching Tilt Switch to Feeder Lid

So now is the time to assemble the tilt switch. What I did for the tilt switch is completely unorthodox, but it works. This is where that 1"x1" block of wood comes into play. I attached the tilt switch to the block of wood, but here is how:

First, I simply cut the block to have a 30 degree angle. I did this, mainly for assurance and ease of mind, so that way when the tilt switch is attached and the lid is shut, the tilt switch will certainly be off. Because the switch closes it's circuit at 30 degrees, I was afraid that if the lid was shut, after having opened it, the tilt switch would still be a closed circuit (meaning that the Arduino will constantly be sending tweets to Twitter every 15 seconds). By cutting the 30 degree angle, gravity works in my favor to pull the ball inside the tilt switch down, thus cutting the connection.

After cutting the block, I drilled a notch into the wood deep enough for the tilt switch to lay snug inside. I filled the notch with super glue, and also put a staple over the tilt switch. This ensures that the switch will not move.

I then soldered the wires from the Arduino to the the tilt switch. I made sure that I had some shrink tube already around the wire so that after I had soldered the wires to the switch, I could cover up that connection by heating up the shrink tube with the side of my soldering iron. The next step is to staple the wires to the side of the block to minimize the movement of the wires. (The wires stemming from the tilt switch are very thin, moving them around too much could break the wires and ruin the switch. Stapling the wires to the block will minimize this movement of wires and prevent them from breaking)

From here, I then put a piece of sticky sided velcro on the bottom of the cut-wood block, and one piece of velcro on top of the lid. I also decided to cover this switch up with a tuber wear container for some protection. The methods for attaching the tuber ware are the same as they were in the last step. Simply put velcro on the container, and in the corresponding place on the lid. Also cut holes in the tuber ware for the wires to pass through. After this, the project just needs to be tested.

Step 7: Step 7: the Final Product!

This is what the finished product looks like. I hope this helped you out! Have fun tweeting!!