Tuesday, July 9, 2013

Twitter Sentimental Bulbs + Ruby!

I presented at the RubyConfIndia 2013 on the topic of Arduino + Ruby and had planned to show 2 Demo's to the attendees.


  1. A bubblino clone and
  2. A webpage controlling a Car.
Unfortunately, both of them stopped working just a day ago because of various reasons. And hence, we came up with a quick hack 'Sentimental Bulbs' which made it to the conference and luckily worked! 

Here is how we built it.

What does sentimental bulbs do?

- It looks for a specific hash-tag on twitter, if the words in that are happy it turns on the green bulb else turns on the red bulb.

How does it work?

- A ruby script runs on the computer tracking tweets and when find a happy tweet sends a message to the Green bulb to light up.

Let's see what does it take to build this.

  1. 2 Bulbs - 1 Red , 1 Green
  2. A relay control board
  3. Ruby Installed + Gem Dino.
  4. Single Strand Wires
  5. Holder for bulbs + plugs to put in mains.


Circuit


  1. Pin no. 12 from Arduino to RL1 pin on Relay control Board
  2. Pin no. 13 from Arduino to RL2 pin on Relay control Board
  3.  + of Relay to +5V on Arduino
  4.  - of Relay to GND on Arduino
  5. Connect the cut wire for green bulb into RL1 and  for red bulb into RL2

Program Logic

  1. Ruby program would listen on twitter with help of tweetstream gem.
  2. Once it detects the pattern of happy words, it sends a signal to switch ON the pin 12. sleeps for some time and then switch it OFF.

Code Repository





No comments:

Post a Comment