Things used in this project

Hardware components:
Ard nano
Arduino Arduino Nano R3
×1
475267 240424 01 front zoom kankcmvqdh
Raspberry Pi Raspberry Pi Zero Wireless
×1
Nema%2017 2
OpenBuilds NEMA 17 Stepper Motor
×1
RGB LED common cathode
×1
Texas instruments l293dne image
Texas Instruments Dual H-Bridge motor drivers L293D
×1
20x4 Character LCD
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
×1
Bourns 3362p 1 103lf image 160px
Single Turn Potentiometer- 10k ohms
×1
11026 02
Jumper wires (generic)
×1
Adafruit industries ada1609 image 75px
Perma-Proto Breadboard Half Size
×1
Software apps and online services:
Ide web
Arduino Arduino IDE
Enthought Canopy (Python IDE)
D94d qxu
Autodesk Fusion 360
Hand tools and fabrication machines:
CNC Router
3drag
3D Printer (generic)
09507 01
Soldering iron (generic)

Custom parts and enclosures

Rotating Candy Mover
Attach to stepper motor
Button
Slot into front plate

Schematics

Schematic
Schematic bb vals7ynooa

Code

Arduino Nano codeArduino
#include <Stepper.h>

const int stepsPerRevolution = 200;

Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
myStepper.setSpeed(30);
Serial.begin(115200);
}

void loop() {
  if(Serial.available()>0){
    char data = Serial.read();
    if (data == 'c'){
      Serial.println("Giving candy!");
      myStepper.step(50);
    }
  }

}
Raspberry Pi CodePython
Copy and paste your Twitter app credentials
from twython import Twython
from time import sleep
import math
import time
import serial
import Adafruit_CharLCD as LCD
import RPi.GPIO as GPIO

lcd_rs        = 27
lcd_en        = 22
lcd_d4        = 25
lcd_d5        = 24
lcd_d6        = 23
lcd_d7        = 18
lcd_backlight = 4

lcd_columns = 20
lcd_rows    = 4

lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, 
                           lcd_columns, lcd_rows, lcd_backlight)
redP = 16
greenP = 20
blueP = 21
buttonP = 5
ser = serial.Serial(port='/dev/ttyS0',baudrate=115200,timeout=1)
pin_list = [redP,greenP,blueP]
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
for pin in pin_list:
    GPIO.setup(pin, GPIO.OUT)
    
GPIO.setup(buttonP, GPIO.IN, pull_up_down=GPIO.PUD_UP)

prev_message = ""

def reset_lcd():
    lcd.clear()
    lcd.home()
    
#copy and paste section below

APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET =  "Consumer Key (API Key)", "Consumer Secret (API Secret)", \
"Access Token", "Access Token Secret"

twitter = Twython(APP_KEY, APP_SECRET,
                  OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

def all_off():
    for pin in pin_list:
        GPIO.output(pin,GPIO.LOW)
        
all_off()

def candy_dispense(channel):
    reset_lcd()
    lcd.message("Dispensing candy\nBe sure to say\n'Trick-or-treat'!")
    ser.write('c')
    sleep(10)
    reset_lcd()

GPIO.add_event_detect(buttonP, GPIO.FALLING, callback=candy_dispense,bouncetime=300)

while 1:
    tweet = twitter.get_mentions_timeline()[0]
    
    reset_lcd()
    
    #if "joke" in tweet['text'].lower() and tweet['text'] != prev_message:
        #client.publish("having11/f/halloween",payload="joke")
    print "Latest tweet: "+tweet['text']+"\n\n"
    text_len = len(tweet['text'])
    if text_len < 20:
        lcd.message(tweet['text'])
    elif text_len > 20 and text_len < 41:
        lcd.message(tweet['text'][0:20]+'\n'+tweet['text'][20:40])
    elif text_len > 20 and text_len < 61:
        lcd.message(tweet['text'][0:20]+'\n'+tweet['text'][20:40]+'\n'+tweet['text'][40:60])
    elif text_len > 20 and text_len < 81:
        lcd.message(tweet['text'][0:20]+'\n'+tweet['text'][20:40]+'\n'+tweet['text'][40:60] \
       + '\n'+ tweet['text'][60:80])                                                                                                

    
    if "color" in tweet['text'].lower():
        if "red" in tweet['text'].lower():
            all_off()
            GPIO.output(redP,GPIO.HIGH)
        elif "green" in tweet['text'].lower():
            all_off()
            GPIO.output(greenP,GPIO.HIGH)
        elif "blue" in tweet['text'].lower():
            all_off()
            GPIO.output(blueP,GPIO.HIGH)
            
    sleep(10)
    reset_lcd()
    lcd.message("From user: \n@"+tweet['user']['screen_name']+"\n"+
                "This will update in\n20 seconds.")
    print "From user: \n@"+tweet['user']['screen_name']+"\nThis will update every 20 seconds\n--------------------------------------"
    sleep(10)
    prev_message = tweet['text']
    

Credits

Download
Arduino “having11” Guy

I love creating cloud solutions that can interact with hardware along with using Arduino boards and Raspberry Pis to create new projects.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Using OV7670 Camera Module With Arduino
Advanced
  • 196
  • 28

Protip

This is an Arduino camera module, using the Surveillance camera's digital image processing chip-OV0706.

Using Nokia 3310 84x48 LCD with Arduino
Advanced
  • 6,015
  • 113

Protip

These 84 by 48 pixel LCDs are what you might have found in Nokia 3310. And what about using them in the Arduino projects?

Banana pi BPI-M2 Zero quad core singel-board computer
Advanced
  • 168
  • 3

Protip

Banana PI BPI-M2 Zero is the open source hardware platform,Banana PI BPI-M2 Zero is an quad core version of Banana Pi,it support WIFI on boa

A Sudoku Solver's Robot
Advanced
  • 2,312
  • 16

Full instructions

Sudoku-robot is a robot that solves and fills Sudoku grids!

Jrobot - Android and Arduino-Based Global Control Robot Car
Advanced
  • 1,825
  • 11

Jrobot adds wheels to mobile phone and makes it truly mobile. Jrobot on 4G has unlimited range and goes anywhere in the world.

Coffeebot: A Bot That Gets Coffee for You
Advanced
  • 658
  • 7

Coffeebot is a coffee delivery robot with one click on the app.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login