Archive for the ‘Code’ Category

Hook up your child’s ball path (or anything else) to Twitter

Sunday, November 20th, 2011

I wanted my son to know whenever I leave work to come home. With a fairly simple Arduino setup the ball of his ball path will be set into motion as soon as one of my tweets contains a certain hashtag.

The code is based on the Pachup example that you can find in O’Reilly’s Arduino Cookbook by Michael Margolis in chapter 15.15 (Download the example code at oreilly.com). To learn more about the wiring you could start at the Analog Input to Servo-Sketch at fritzing.org.

Parts:

  • Arduino Uno (Sparkfun’s SKU: DEV-09950)
  • Arduino Ethernet Shield (Sparkfun’s SKU: DEV-09026)
  • Servo Motor
  • Network Cable
  • Power Plug for the Arduino Uno
  • A ball path

(If you need a shortcut, get the Fritzing Starter Kit.)

Step 1:
Figure out a way to release the ball of the ball path using the servo motor. In my case it was pretty simple. I could make it look nicer, but for the time being the solution presented in the picture below will do.

 

Step 2:
Add the following libraries to your Arduino IDE:

Step 3:

  • Open BallPath_Version1.pde in your Arduino IDE
  • Modify the two variables [YOUR_TWITTER_ID] and [YOUR_HASHTAG]
  • Compile it and send it to your Arduino Uno.

Step 4:
Add the Ethernet Shield on top of the Arduino Uno and wire the servo motor according to the sketch below.

  

Step 5:
Hook up your Aduino to your network and attach the power plug.
Your Arduino should be booting now. The servo motor will stay at an angle of 10° until the IP address is received. In case the DNS lookup failed, the motor will be turned to 50°. (In case you need more than this servo-based logging change the value of “loggingEnabled” to TRUE and open the serial monitor of the IDE.)

Result:
Now you’re done. The code will check every 8 minutes for a new tweet with the hashtag specified. (If you would like to increase that value please make sure to check the API documentation for the max-request value.)
As soon as the Arduino receives a search result containing your hashtag the servo motor will be turned to 180° to release the ball. You might have to change this value according to your needs.

The video below demonstrates the systems.

If you find any bugs or if you improved the code, please let me know. Any feedback is welcome.

Rabbits on Ruby

Wednesday, April 29th, 2009

How my green RFID-Rabbit learned to talk to Ruby on OpenBSD:

  • Connect the USB-mir:ror to the computer (in my case, it’s my ALIX)
  • #git clone git://github.com/leh/ruby-mirror.git
  • #dmesg | grep Violet
    uhidev0 at uhub1 port 1 configuration 1 interface 0 “Violet Mirror” rev 1.10/1.00 addr 2
  • # sudo chmod o+r /dev/uhid0
  • # vi bin/ruby_mirror >> change device-path to /dev/uhid0
  • # sudo ruby bin/ruby_mirror examples/bunny.mir
    hey d002xxxxxxxxxxxx, never seen you before

For more information refer to ruby-mirror and to Mir:ror.

[To be continued soon.]

29042009(001).jpg

All systems up and running.

Friday, December 19th, 2008

Just upgraded my WordPress installation. I needed the latest version for a little test drive at work.

And: I accidentally upgraded the WordPress database tables of funk-station.com (please don’t tell me anything about a clear separation of concerns, I know, I know). The WordPress version of funk-station.com has not been updated for years — maybe two, maybe three, I don’t remember. Guess what: I didn’t have to do much except for deleting a few strange php-calls of antique plug-ins we installed years ago.

WordPress is wonderful.

Mercurial & OS X 10.5: “unknown locale: UTF-8″

Saturday, October 25th, 2008

It took me too long to find a solution for this problem. Hopefully this post will speed up the search of someone else.

Installing Mercurial on OS X 10.5 (Leopard) worked fine. Running the hg command resulted in the following error message:

File "/usr/local/bin/hg", line 18, in <module>
mercurial.util.set_binary(fp)
File "/Library/Python/2.5/site-packages/mercurial/demandimport.py", line 74, in __getattribute__
self._load()
File "/Library/Python/2.5/site-packages/mercurial/demandimport.py", line 46, in _load
mod = _origimport(head, globals, locals)
File "/Library/Python/2.5/site-packages/mercurial/util.py", line 33, in <module>
_encoding = locale.getlocale()[1]
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 460, in getlocale
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/locale.py", line 373, in _parse_localename
ValueError: unknown locale: UTF-8

Of course UTF-8 as a locale does not make any sense at all. The solution is hidden in the preferences of Terminal.app. Disable “Set LANG environment variable on startup”, exit Terminal.app, restart, and hg will work.


Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Germany License.

Switch to our mobile site