Introduction: Raspberry Pi Twitter Candy Bot

Picture of Raspberry Pi Twitter Candy Bot

Video of all steps at a high level


Materials

  • Raspberry Pi (If this is your first time you may also need monitor, keyboard, and mouse)
  • Servo
  • WiFi Adapter or Ethernet cable
  • Wires with female plugs for connecting to Raspberry PiCandyPlastic pop-bottle or similar container.

Step 1: Setup Raspberry Pi With Rasbian

If you have not used a raspberry pi before please see the Raspberry Pi website: http://www.raspberrypi.org/help/quick-start-guide/

If you have your raspberry pi up and running with Rasbian skip this step.

Step 2: Setup NodeJS on Your Raspberry Pi

The candy dispensing code I have written is in JavaScript and runs on NodeJS, so you will need to install NodeJS on your raspberry pi.

WeWorkWePlay has a great tutorial for this:

http://weworkweplay.com/play/raspberry-pi-nodejs/

Step 3: Setup WiFi on Raspberry Pi Startup

If you want to use wifi, then you will need to setup your raspberry pi to connect automatically when it starts up.

You will need to edit /etc/network/interface to include the name and password for your wireless network.

Tutorial: http://raspberrypihq.com/how-to-add-wifi-to-the-ra...

Step 4: Setup the Candy-bot Code

Download or Fork it from GitHub: https://github.com/davidrs/candy-pi

Save it to your Raspberry Pi: /home/pi/candy-pi

Create a developer account for the Twitter API: https://apps.twitter.com/

On the Twitter App site add a new app and generate an API key.

Update the config.js with your Twitter API key.

Test locally: `npm index`

Setup your Raspberry Pi to run the code on startup. (see tutorial in step 2 for details)

Step 5: Connect Servo

Last step is to wire up your servo.

This will vary servo to servo, but roughly, you will have three wires positive, negative(ground), and control signal.

On my servo it is:

Brown - ground

Red - positive

Orange - control (I used GPIO pin 4)

For small servos you can run it off the Raspi 5v pin for positive and the Raspi ground, but best practice is to use an independent power source, such as batteries or a wall plug. For the control wire you plug it into the pin specified in hardware.js in the code. default is pin 4.

Comments

lewaal3531 (author)2017-05-08

Hello, I know how to set this up but the sign @DGateway is in the way so maybe can you remove and take another picture of it without the sign @DGateway in it that would be great thank you so much!!

JaredL8 (author)2016-11-01

Hey... in the README file, it says to run npm index to execute the code. When I do that, it just gives me the syntax of the the npm command. It does not actually run anything. If I run npm run index I get some output that says 'missing script: index. So I tried 'npm run index.js' and I get 'missing script index.js'. Then I tried 'npm run ./index.js' annd got 'missing script ./index.js.

If I do 'sudo npm start' from within the candy-pi-master folder, it looks as if something is working and it says

sudo npm start

> led@0.0.0 start /pi/smb/candy-pi-master

> node server.js

Listening on port 3001

Is that what it should be saying if it is working?

matisok (author)2015-04-14

Hi David. Your project is cool. Just the thing I'd like to make. Is there a step describing how to wire up the servo to the GPIO pins? Or is this self explanatory from looking at the code?

davidrs1 (author)matisok2015-04-14

Hi Matisok, I'm glad you like it. For the GPIO pins for the servo it is pretty straight forward. Look up the specs for your particular servo but mine was: brown to ground, red to 5v, and orange to control.

I connected my control to GPIO pin 4

hardware.js is where it is set.

piblaster.setPwm(4, this.openAngle);

Small servos can use the 5v form the Raspi, but best practice is to connect to an independent power source for + and -

matisok (author)davidrs12015-04-15

Hi again,

Thanks for updating the steps with the GPIO, although it's pretty basic!

Another question: where do you edit the twitter keyword? You mention it in the video, but it is not obvious (to me) where you edit it in the files.

Thanks.

MsSweetSatisfaction (author)2014-12-29

Ooo that looks like fun, probably a great way to surprise someone! Welcome to instructables! I hope we see more from you in the future!

About This Instructable

12,028views

32favorites

License:

More by davidrs1:Raspberry Pi Twitter Candy Bot
Add instructable to: