Raspberry Pi Twitter Candy Bot

Video of all steps at a high level


  • 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.Raspberry Pi Twitter Candy Bot

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:


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)Raspberry Pi Twitter Candy Bot schematic

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.


For more detail: Raspberry Pi Twitter Candy Bot

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top