Arduino Sonar Buzzer PHP Twitter Thingy

i haven’t posted in a while, but that doesn’t mean i haven’t been doing cool stuff in what little spare time i have. i thought i’d finally record one cool project i finished.

i’m not sure what to call it other than “dynamic awareness”. in a nutshell, i interface a Maxbotix LV-EZ2 ultrasonic range-finder to my arduino diecimilia, along with a generic buzzer.

using serproxy, i channeled serial data running through my computer to network traffic. on my machine running a wamp server, i wrote a few php scripts to read the values and with ajax (using jquery) change the color of the screen to green (the farther you are) to red (the closer you are). also, the closer you get, the smaller you get.

and of course, what would a project be like these days without something twittering. you can see what this project twitters here. basically, i operated under the assumption that the closest thing to a realistic use of this system would be twitter whether or not you are at your desk.

so what does this thing do again?

arduino & sonar returns your distance away from the computer and it is displayed on the screen. the farther away you are from the computer the larger the text and the greener the screen. the closer you are, the smaller the text and the redder the screen. get within 5 inches and a buzzer alarms. distance is twittered.

how did i do the color changing?

i just used jquery to dynamically tweak the background rgb values based on the % change in distance from the screen. rgb(red,green,blue)

where’s the source?

you can download it here.
For now, the source is not available. However, if you want it really bad, you can email me and ask for it.

watch the video of how it works

arduino sonar buzzer php twitter from Joshua McGinnis on Vimeo.

View Realtime Requests Per Second From Log

so you want to view the number of requests to your webserver per second. here’s a quick and easy php script that you can run from command line.

    echo exec('cat /var/log/httpd/access_log | wc -l') . "n";

it isn’t perfect, but it will work for doing some basic troubleshooting. just hit ctrl+c to terminate.

and if you want to simulate a bunch of request so you can watch the num go up and down, here’s a script to help:

while(true) {

csv to associative array

i’ve been working a major integration project with quickbase and vtrenz. one of the things i had to do this week was take a ~10K row csv, scrub the cells for specific length, and then ftp to a remote server.

so i wrote a php script that would connect to quickbase, pull down the csv, write it to file, open it, turn the csv into an array, scrub it, recreate the csv from the array, write it to file again, and then send it on it’s merry way ala ftp.

all of it was easy except turning the csv into an array. i didn’t want to step through each character looking for newlines or my delimeter (a comma) and i needed something that would use the first row of the csv as the column headings.

i was able to find some scripts on the web that half-way worked. in fact, the one i used before writing my own worked, it was just super slow and inefficient. it literally used a gig of memory for 5K records.

so here’s my solution for taking a very large csv, and using the first row to create a key=>value associative array.

function buildStock($File) {
  $handle = fopen($File, "r");
  $fields = fgetcsv($handle, 5000, ",");

  $y = 0;
  while($data = fgetcsv($handle, 5000, ",")) {
    $x = 0;
    foreach($data as $value) {
      $stock[$y][$fields[$x]] = $value;
   return $stock;

it now only takes a few seconds to turn a considerably large csv into an array. hope this helps someone out there.

How to Pass Arguments to PHP in Command Line

I did a little bit of searching this morning for how to pass arguments to php via command line because I was working on setting up a php script to run on a cron in Windows (using WAMP).

It’s actually pretty easy. Say your command line looks like this:

>path-to-php/php.exe path-to-script/script.php

Passing an argument to the php script would look like this:

>path-to-php/php.exe path-to-script/script.php arg1 arg2

PHP will read the arguments using the $argv variable. So in our example, $argv[0] would be the name of the script (script.php), $argv[1] would be arg1 and $argv2[2] would be arg2.

Another example:
>path-to-php/php.exe path-to-script/script.php 15

Say you just wanted to echo out the argument contents:

echo $argv[1];

Pretty cool. Here’s the forum post where I discovered this information.

demo: rfid reader + arduino for point of sale solution

i’ve put together this video as a demo of “intuit checkout” – the idea that won the last intuit ideajam contest.

intuit checkout is a low-cost point of sale hardware/software solution that uses an arduino prototyping board and a parallax rfid reader.

all of the item data associated with the unique ids on the rfid’s are stored securely in a quickbase online database.

Continue Reading

How to Enable libcurl in WAMP

Are you are getting “Fatal error: Call to undefined function: curl_init()” and you’re using WAMP, you’ve got to perform a few extra steps to get cURL working.

Wamp comes with a lot of extensions, including cURL, it is just a matter of getting the extension loaded when wamp is started. And no, enabling php_curl from within the wamp menu is not how to do it.

For some reason, that just doesn’t work.

How to Enable libcurl in WAMP

Here are the steps for getting cURL enabled in WAMP.

Step 1

  • Open C:wamp\bin\php\php5.2.6\php.ini
  • Find “;extension=php_curl.dll” and remove the semicolon to uncomment the line
  • Do the same for C:wamp\bin\apache\apache2.2.8\bin\php.ini

Note: the version of WAMP you’re running does not really matter. The step should be the same for all versions.

Step 2

Next, you need to make sure apache can find the extension to load, so make sure that in both php.ini files, you find the lines:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\wamp\bin\php\php5.2.6\ext"

Make them both point to the ext folder within your PHP folder. By default, they will be set to something like /usr/bin/ext. This is what you will need to change.

Step 3

Restart wamp and it should all work. You can look in the phpinfo() to see if cURL was loaded. If it still doesn’t work, check the apache error log within the wamp logs folder for additional clues.

Good luck!

2008 National Small Business Summit Ad

Small Business Summit 2008 Print Ad

In September of 2009, in preparation for Intuit QuickBase’s participation in the 2008 National Small Business Summit, I worked closely with the QuickBase marketing team to execute on a campaign to drive leads from our ad to our website.

As a part of this project, I designed the ad for the summit brochure. In addition, I also built the landing page and ensured that all traffic was logged and leads were properly tracked.

Jabbify Chat Client

This mockup is a proof of concept design of the Jabbify web chat client. Jabbify is a new start-up that makes a pretty neat instant messaging client that anyone can put on their website. Since Jabbify’s launch, I’ve been providing basic design consultation in my free time.

Jabbify Client

Related URL:

Intuit WorkPlace

Intuit Workplace

Intuit Workplace is the soon to be center point of everything QuickBase Developer Program. It needed a new website before a major press-release so Rob Keohane (QuickBase UX Lead) and I put together the Workplace homepage at the last minute.

In this particular piece, I did the XHTML markup and CSS while Sr. UX Designer Rob Keohane worked on the design.

If you’re a developer and at all interested in developing web-based applications in Adobe Flex, I encourage you to apply.

[button text=”Launch Workplace” url=”” target=”_blank”]

Note: The design mentioned above is no longer active on the website.

PHP API Wrapper (SDK) for QuickBase

For the latest on the QuickBase PHP SDK, please see this post.

The information below is not currently being maintained and may not present the latest news, information and code regarding the QuickBase PHP SDK.

For anyone interested in using PHP with QuickBase, here is a PHP wrapper. It uses cURL to post XML and HTTP POSTS to QuickBase. Big thanks to Alex Wilson for providing most of the original code base. The documentation for the QuickBase API can be found here.

Continue Reading