<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>exploration &#187; hacking</title>
	<atom:link href="http://robertcarlsen.net/tag/hacking/feed" rel="self" type="application/rss+xml" />
	<link>http://robertcarlsen.net</link>
	<description>accounts of success and misadventure</description>
	<lastBuildDate>Tue, 13 Jul 2010 14:37:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Toy Design: Talking Blocks sketches</title>
		<link>http://robertcarlsen.net/2009/04/07/toy-design-talking-blocks-sketches-620</link>
		<comments>http://robertcarlsen.net/2009/04/07/toy-design-talking-blocks-sketches-620#comments</comments>
		<pubDate>Tue, 07 Apr 2009 18:29:11 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Toy Design]]></category>
		<category><![CDATA[itp]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[atmega]]></category>
		<category><![CDATA[avr]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[cad]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[qcad]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=620</guid>
		<description><![CDATA[Alex and I have been developing the plans for the blocks in preparation for building the prototypes in the next week. For this, I built the community edition of QCad (open source FTW!) and have been teaching myself how to draw with it. There was a bit of a learning curve to the interface and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/04/sketch_v01_dark.png" rel="lightbox[620]"><img class="alignright size-thumbnail wp-image-621" title="sketch_v01_dark" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/04/sketch_v01_dark-150x150.png" alt="sketch_v01_dark" width="150" height="150" /></a>Alex and I have been developing the plans for the blocks in preparation for building the prototypes in the next week. For this, I built the community edition of <a href="http://www.ribbonsoft.com/qcad_downloads.html" onclick="pageTracker._trackPageview('/outgoing/www.ribbonsoft.com/qcad_downloads.html?referer=');">QCad</a> (open source FTW!) and have been teaching myself how to draw with it. There was a bit of a learning curve to the interface and the modal model of the application tools, but I&#8217;m now relatively comfortable with the basics.<span id="more-620"></span></p>
<p>Alex made several physical models of the blocks in styrofoam, which determined that 67mm is the most desirable size for the cubes. After casting a test, hollow cube of silicone, we decided that given the pliability of the material we&#8217;d need at least 15mm thick walls. Using these measurements I started sketching out the components as the might be assembled inside the form.</p>
<p>Currently, we plan to have the blocks respond the their orientation as children hold them. The blocks will change colors and vary the color pulsing rate as they are tumbled. Shaking a block will cause it to &#8220;call out&#8221; to other nearby blocks using IR communication. We&#8217;re still determining the effective function of the talking, but we&#8217;re thinking of having the colors or pulse rate transfer to the listening blocks. Each block that receives a message will relay it in turn, hopefully contributing to a &#8220;bucket brigade&#8221; or domino effect.</p>
<p>We&#8217;re looking to use the ATmega168 chip for the prototypes as they are cheap and we&#8217;re comfortable using them – having come from an Arduino background. Of course, with the timing necessary for the IR encoding and decoding, plus the color variations needed for the RGB LED, we&#8217;ve had to dive into the C code and use the mega168&#8217;s interrupts directly.</p>
<p>Using these sketches I&#8217;ll lay out a circuit that we can prototype on a perf board or even etch some sample boards. We&#8217;re still working out the power supply&#8230;but I think that getting the user experience right for this first version trumps the practicality goals at this point.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/04/arduino_ir_communication.jpg" rel="lightbox[620]"><img class="alignleft size-medium wp-image-622" title="arduino_ir_communication" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/04/arduino_ir_communication-300x237.jpg" alt="arduino_ir_communication" width="300" height="237" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/04/07/toy-design-talking-blocks-sketches-620/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>openFrameworks + iPhone libs</title>
		<link>http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593</link>
		<comments>http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593#comments</comments>
		<pubDate>Thu, 26 Mar 2009 04:09:19 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[lib]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[makefile]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=593</guid>
		<description><![CDATA[I&#8217;ve had a few days to test the libraries I cobbled together for using openFrameworks with iPhone and also received positive reports from some folks who tried out the Makefiles I provided to them, so here they are for anyone who&#8217;s willing to try them out. -please make these instructions better if you see fit- [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/of_iphone.png" rel="lightbox[593]"><img class="alignright size-full wp-image-604" title="of_iphone" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/of_iphone.png" alt="of_iphone" width="123" height="119" /></a>I&#8217;ve had a few days to test the libraries I cobbled together for using openFrameworks with iPhone and also received positive reports from some folks who tried out the Makefiles I provided to them, so here they are for anyone who&#8217;s willing to try them out. -please make these instructions better if you see fit- <span id="more-593"></span></p>
<p>Update (7.8.2009): Fixed some errant quote mark substitutions in the freetype configure line. Also corrected a tab formatting error in the freeimage makefile.</p>
<p>Ok, here goes. This is going to be a work-in-progress document. Of course, there are no promises with this and your mileage may vary&#8230;but it&#8217;s been working for me. Please report success (and trouble, hopefully with workarounds).</p>
<p>The basic &#8220;tutorial&#8221; I followed is on Memo Akten&#8217;s blog, <a href="http://memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone" onclick="pageTracker._trackPageview('/outgoing/memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone?referer=');">memo.tv</a></p>
<p>I&#8217;d highly suggest following Memo&#8217;s tutorial for setting up the development environment. However, there are three libraries that he mentions in his article that need to be built for the iPhone specifically: <a href="http://code.google.com/p/iphone-glu/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/iphone-glu/?referer=');">glu</a>, <a href="http://www.freetype.org/" onclick="pageTracker._trackPageview('/outgoing/www.freetype.org/?referer=');">freetype</a> and <a href="http://freeimage.sourceforge.net/" onclick="pageTracker._trackPageview('/outgoing/freeimage.sourceforge.net/?referer=');">freeimage</a>. Although he mentions that they have been ported to iPhone I wasn&#8217;t able to locate binaries of the libraries, and went through the process of cross-compiling them myself. This post documents what I needed to do to accomplish that.</p>
<p>You&#8217;ll need to download the source for each of the libraries listed above, as well as a svn copy of open frameworks plus the <a href="http://code.google.com/p/ofxiphone/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/ofxiphone/?referer=');">ofxiPhone</a>, <a href="http://code.google.com/p/ofxmsaof/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/ofxmsaof/?referer=');">ofxMultiTouch and ofxAccelerometer</a> addons. I preferred to use <a href="http://github.com/lian/ofx-dev/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/lian/ofx-dev/tree/master?referer=');">ofx-dev</a> which bundled this and many more addons. You also need the <a href="http://developer.apple.com/" onclick="pageTracker._trackPageview('/outgoing/developer.apple.com/?referer=');">Apple Developer Tools</a> including Xcode and the iPhone SDK.</p>
<p><strong>GLU for iPhone:</strong><br />
The glu for iphone package builds painlessly. Build twice: once for the iPhone, once for the iPhone Simulator. Make sure to do a &#8220;make clean&#8221; before building the second version. The readme explains the make command. I copied the entire folder to ofx-dev/libs/gluiphone</p>
<p>The other two were more difficult for me. I&#8217;ve never cross-compiled, so perhaps that contributed to the trouble I had.</p>
<p><strong>FreeImage:</strong><br />
Here is the makefile that I came up with, based on the existing files and what I saw in the glu makefile. Copy the makefile listed below as &#8220;Makefile.iphone&#8221; alongside the others in the source directory, then run &#8220;make -f Makefile.iphone&#8221;. This should build both the iPhone and iPhone Simulator libraries into the &#8220;Dist&#8221; folder. Copy both files to ofx-dev/libs/freeimage/lib</p>
<div style="max-width:550px">
<pre class="brush: cpp; wrap-lines: false;">
# Configuration for iPhone OS, making static libs
# this will generate both iPhone (arm) and iPhoneSimulator (i686) libs

include Makefile.srcs

CFLAGS =  -g -O2 -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing
CXXFLAGS =  -g -O2 -Wall -fno-strict-aliasing

GCC_VERSION = 4.0
IPHONEOS_DEPLOYMENT_TARGET = 2.1
MACOSX_DEPLOYMENT_TARGET = 10.5

PLATFORM_SIM = iPhoneSimulator
PLATFORM_PHONE = iPhoneOS

ARCH_SIM = i686
ARCH_PHONE = armv6

PLATFORM_SIM_DEVELOPER_BIN_DIR = /Developer/Platforms/$(PLATFORM_SIM).platform/Developer/usr/bin
PLATFORM_PHONE_DEVELOPER_BIN_DIR = /Developer/Platforms/$(PLATFORM_PHONE).platform/Developer/usr/bin

SDKROOT_SIM = /Developer/Platforms/$(PLATFORM_SIM).platform/Developer/SDKs/$(PLATFORM_SIM)$(IPHONEOS_DEPLOYMENT_TARGET).sdk
SDKROOT_PHONE = /Developer/Platforms/$(PLATFORM_PHONE).platform/Developer/SDKs/$(PLATFORM_PHONE)$(IPHONEOS_DEPLOYMENT_TARGET).sdk

EXTRA_CFLAGS_SIM += -arch $(ARCH_SIM) -pipe -mdynamic-no-pic -fvisibility=hidden $(INCLUDE) -isysroot $(SDKROOT_SIM)
EXTRA_LDFLAGS_SIM += -arch $(ARCH_SIM) -isysroot $(SDKROOT_SIM) -Wl,-dead_strip
EXTRA_CFLAGS_SIM += -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)
EXTRA_LDFLAGS_SIM += -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET)

EXTRA_CFLAGS_PHONE += -arch $(ARCH_PHONE) -pipe -mdynamic-no-pic -fvisibility=hidden $(INCLUDE) -isysroot $(SDKROOT_PHONE)
EXTRA_LDFLAGS_PHONE += -arch $(ARCH_PHONE) -isysroot $(SDKROOT_PHONE) -Wl,-dead_strip
EXTRA_CFLAGS_PHONE += -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)
EXTRA_LDFLAGS_PHONE += -miphoneos-version-min=$(IPHONEOS_DEPLOYMENT_TARGET)

AR_SIM = $(PLATFORM_SIM_DEVELOPER_BIN_DIR)/ar
AR_PHONE = $(PLATFORM_PHONE_DEVELOPER_BIN_DIR)/ar

CC_SIM = $(PLATFORM_SIM_DEVELOPER_BIN_DIR)/gcc-$(GCC_VERSION)
CC_PHONE = $(PLATFORM_PHONE_DEVELOPER_BIN_DIR)/gcc-$(GCC_VERSION)

CFLAGS_SIM = $(CFLAGS) $(EXTRA_CFLAGS_SIM)
LDFLAGS_SIM = $(EXTRA_LDFLAGS_SIM)
CXX_SIM = $(PLATFORM_SIM_DEVELOPER_BIN_DIR)/g++-$(GCC_VERSION)
CXXFLAGS_SIM += $(EXTRA_CFLAGS_SIM) -fvisibility-inlines-hidden
LIBTOOL_SIM = /Developer/Platforms/$(PLATFORM_SIM).platform/Developer/usr/bin/libtool

CFLAGS_PHONE = $(CFLAGS) $(EXTRA_CFLAGS_PHONE)
LDFLAGS_PHONE += $(EXTRA_LDFLAGS_PHONE)
CXX_PHONE = $(PLATFORM_PHONE_DEVELOPER_BIN_DIR)/g++-$(GCC_VERSION)
CXXFLAGS_PHONE += $(EXTRA_CFLAGS_PHONE) -fvisibility-inlines-hidden
LIBTOOL_PHONE = /Developer/Platforms/$(PLATFORM_PHONE).platform/Developer/usr/bin/libtool

TARGET = freeimage
STATICLIB_SIM = lib$(TARGET)-iphonesimulator.a
STATICLIB_PHONE = lib$(TARGET)-iphone.a
HEADER = Source/FreeImage.h

.SUFFIXES: .o-i686 .o-arm
MODULES_ARM = $(SRCS:.c=.o-arm)
MODULES_ARM := $(MODULES_ARM:.cpp=.o-arm)
MODULES_i686 = $(SRCS:.c=.o-i686)
MODULES_i686 := $(MODULES_i686:.cpp=.o-i686)

default: all

all: dist

dist: FreeImage
	cp *.a Dist
	cp Source/FreeImage.h Dist

FreeImage: $(STATICLIB_SIM) $(STATICLIB_PHONE)

$(STATICLIB_SIM): $(MODULES_i686)
	$(LIBTOOL_SIM) -arch_only i686 -o $@ $(MODULES_i686)

.c.o-i686:
	$(CC_SIM) $(CFLAGS_SIM) -c $&lt; -o $@

.cpp.o-i686:
	$(CXX_SIM) $(CXXFLAGS_SIM) -c $&lt; -o $@

$(STATICLIB_PHONE): $(MODULES_ARM)
	$(LIBTOOL_PHONE) -arch_only armv6 -o $@ $(MODULES_ARM)

.c.o-arm:
	$(CC_PHONE) $(CFLAGS_PHONE) -c $&lt; -o $@

.cpp.o-arm:
	$(CXX_PHONE) $(CXXFLAGS_PHONE) -c $&lt; -o $@

clean:
	rm -f core Dist/*.* u2dtmp* $(MODULES_i686) $(MODULES_ARM) $(STATICLIB_SIM) $(STATICLIB_PHONE)
</pre>
</div>
<p><strong>FreeType:</strong><br />
Their makefile situation got me all confused so i just passed command like configure arguments as necessary. This is pretty ugly. -Please make this better someone-</p>
<div style="max-width:550px">
<pre class="brush: cpp; wrap-lines: false;">
#building freetytpe for iphone
# for iPhone
./configure --prefix=/usr/local/iphone --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1 CFLAGS=&quot;-arch armv6 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -I/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/include/libxml2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk&quot; CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar LDFLAGS=&quot;-arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -Wl,-dead_strip -miphoneos-version-min=2.0&quot;

# for iPhone simulator
./configure --prefix=/usr/local/iphone --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 CFLAGS=&quot;-arch i686 -pipe -mdynamic-no-pic -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -mmacosx-version-min=10.5  -I/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/include/ -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk&quot; CPP=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ar LDFLAGS=&quot;-arch i686 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk -Wl,-dead_strip -mmacosx-version-min=10.5&quot;
</pre>
</div>
<p>Run one of the configure lines, then make. I got an error about &#8220;asm&#8221; being undefined&#8230;I think it was in include/freetype/config/ftconfig.h. Change &#8220;asm&#8221; to &#8220;__asm__&#8221; (that&#8217;s two underscores for both prefix and suffix). If it works then it drops the lib in a hidden dir: &#8220;./objs/.libs&#8221;.  Copy the static lib out of there and rename it as appropriate.  i&#8217;m using libfreetype-iphone.a and libfreetype-iphonesimulator.a. Run make clean and then run the other configure line and make again. There were some headers missing in from the freetype lib provided with ofx-dev that I noticed in the example ofxiPhone aps&#8230;so I copied the entire freetype folder to ofx-dev/libs/freetype-iphone. I put the libraries into freetype-iphone/lib so i could keep everything straight when setting up xcode.</p>
<p>Ok, I think this gets up to the point where we can set up xcode.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/ofxiphone_xcode.png" rel="lightbox[593]"><img class="alignright size-thumbnail wp-image-602" title="ofxiphone_xcode" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/ofxiphone_xcode-150x150.png" alt="ofxiphone_xcode" width="150" height="150" /></a>Copy one of the ofxiPhone examples to ofx-dev/apps/dev and open it up in xcode. I used the Graphics example. There is some more explanation on Memo&#8217;s site about the project structure, but it was very similar to adding any other addons. However, I put gluiphone, freetype-iphone and freeimage into the libs&gt;core&gt;core libraries package in the xcode project. I&#8217;ve attached a screenshot to illustrate better than i can explain. (ofxVectorMath is there for the specific project i have open, is not required).</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/user-search-paths.png" rel="lightbox[593]"><img class="alignleft size-thumbnail wp-image-603" style="margin-right: 2px;" title="user-search-paths" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/user-search-paths-150x150.png" alt="user-search-paths" width="150" height="150" /></a></p>
<p>Go to menu Project&gt;Edit Project Settings&#8230; and switch to the build tab. Set configuration to &#8220;All Configurations&#8221; and add in the library and header search paths as appropriate&#8230;just like setting up addons.</p>
<p>Set the Overview to Simulator &#8211; 2.0 | Debug and try to build. Make sure that all the appropriate libraries have been added to the Target. xcode seems to be able to pick the correct ones for the given architecture.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/library-search-paths.png" rel="lightbox[593]"><img class="size-thumbnail wp-image-601 alignright" title="library-search-paths" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/library-search-paths-150x125.png" alt="library-search-paths" width="150" height="125" /></a></p>
<p>I initially got an error about a bad BOOL typedef in FreeImage.h:130 I changed it to typedef int8_t BOOL. In perhaps a separate issue, I don&#8217;t seem to be able to use the &#8220;Boolean&#8221; datatype, but can replace it with &#8220;bool&#8221; instead.</p>
<p>So, that&#8217;s what I did to get my system all set up to use openFrameworks with the iPhone. Feel free to let me know how it works out if you use this for yourself. Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/03/25/openframeworks-iphone-libs-593/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>openFrameworks + iPhone</title>
		<link>http://robertcarlsen.net/2009/03/16/openframeworks-iphone-586</link>
		<comments>http://robertcarlsen.net/2009/03/16/openframeworks-iphone-586#comments</comments>
		<pubDate>Mon, 16 Mar 2009 23:57:09 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[openframeworks]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[particles]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=586</guid>
		<description><![CDATA[I&#8217;ve heard about openFrameworks 0.6 (as of yet unreleased) and specifically efforts to support building apps using oF for the iPhone. There are a few developers who have published videos of their efforts and even several apps in the AppStore.
Memo Atken has a very informative article about setting up the prerelease 0.6 version for use [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/particles-iphone.png" rel="lightbox[586]"><img class="alignright size-thumbnail wp-image-587" title="particles-iphone" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/03/particles-iphone-150x150.png" alt="particles-iphone" width="150" height="150" /></a>I&#8217;ve heard about openFrameworks 0.6 (as of yet unreleased) and specifically efforts to support building apps using oF for the iPhone. There are a few <a href="http://leebyron.com/how/2008/08/31/iphone-yellowtail/" onclick="pageTracker._trackPageview('/outgoing/leebyron.com/how/2008/08/31/iphone-yellowtail/?referer=');">developers</a> who have published videos of their efforts and even several apps in the AppStore.</p>
<p>Memo Atken has a very <a href="http://memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone" onclick="pageTracker._trackPageview('/outgoing/memo.tv/developing_for_iphone_using_openframeworks_and_ofxiphone?referer=');">informative article</a> about setting up the prerelease 0.6 version for use with the ofxiPhone addon. However, there is a HUGE simplification of the steps necessary for getting the supporting libraries installed for use with iPhone.</p>
<p><strong>Update: </strong>freetype/freeimage building instructions have been <a href="http://robertcarlsen.net/blog/2009/03/25/openframeworks-iphone-libs-593">posted.</a><span id="more-586"></span></p>
<p>GLU, FreeType and FreeImage need to be built for use with the iPhone. GLU has a nice <a href="http://code.google.com/p/iphone-glu/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/iphone-glu/?referer=');">iPhone specific project</a> and worked flawlessly. I looked around to see if there were ARM/iPhone built versions of the FreeImage and FreeType libraries already available, but couldn&#8217;t find anything. In the end, I hacked up their respective Makefiles and configure options and eventually got everything compiled. I&#8217;ve never had to manually cross-compile code, and I don&#8217;t *actually* know what I&#8217;m doing&#8230;but I can sure copy-paste like a fiend.</p>
<p>Eventually, I&#8217;ll post the specific changes I made, but I want to test it a bit before I expose my embarrassing level of hackery. In the meantime let me know if you&#8217;re itching to get your own environments set up and I&#8217;ll do what I can.</p>
<p>For my &#8220;hello world&#8221; app I ported the particle system from the TrafficFlow project over to the iPhone. It was originally written using oF 0.5 and c++ in xcode, so it was relatively trivial to update for the iPhone with the ofxiPhone addon. I&#8217;m using <a href="http://github.com/lian/ofx-dev/tree/master" onclick="pageTracker._trackPageview('/outgoing/github.com/lian/ofx-dev/tree/master?referer=');">ofx-dev</a> as the codebase. Using the built-in multi touch library sure beats building the computer vision tracking we&#8217;re using for the table! Teaser video below.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/to70HMNxhVc&#038;fs=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/to70HMNxhVc&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/03/16/openframeworks-iphone-586/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>(Signal to) Noise meter + Mail</title>
		<link>http://robertcarlsen.net/2009/01/16/signal-to-noise-meter-mail-304</link>
		<comments>http://robertcarlsen.net/2009/01/16/signal-to-noise-meter-mail-304#comments</comments>
		<pubDate>Fri, 16 Jan 2009 23:53:30 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[itp]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[4in4]]></category>
		<category><![CDATA[analog]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=304</guid>
		<description><![CDATA[(ITP 4-in-4 day 4+1, or how i learned to stop worrying and love blowing deadlines)
to complete the signal to noise meter previously posted i wrote up an apple script which calculates a ratio of messages in my mail inbox to the junk messages which have been caught. the apple script then sends that ratio via [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-305 alignright" style="margin-left: 3px; margin-right: 3px;" title="emaildayoff_snippet" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/01/emaildayoff_snippet.png" alt="emaildayoff_snippet" width="49" height="291" />(ITP 4-in-4 day 4+1, or how i learned to stop worrying and love blowing deadlines)</p>
<p>to complete the signal to noise meter previously posted i wrote up an apple script which calculates a ratio of messages in my mail inbox to the junk messages which have been caught. the apple script then sends that ratio via serial to the signal to noise meter. i&#8217;ve set up a rule in mail.app to trigger the script every time a message comes in. the serial output (ascii only, it seems) is thanks to <a href="http://mysite.verizon.net/vzenuoqe/MacSoft.html" onclick="pageTracker._trackPageview('/outgoing/mysite.verizon.net/vzenuoqe/MacSoft.html?referer=');">SerialPort X</a>.</p>
<p>it&#8217;s certainly not perfect&#8230;having a lot of read messages stagnating in the inbox brings the ratio down&#8230;but i&#8217;m posting the code below so maybe someone can figure a better way.</p>
<p>also, the script wasn&#8217;t triggering when called directly from mail&#8217;s rules&#8230;my workaround was to have a launcher script run &#8216;do shell script &#8220;osascript &#8221; signalToNoise.scpt&#8217;. for some reason this worked when the launcher script was triggered by mail &#8211; YMMV.</p>
<p>oh! it just when off as i was writing this entry&#8230;the light came on, and the needle swung high&#8230;.i need to clean out the junk mail!</p>
<p>code after the break (i always wanted to write &#8220;after the break&#8221;)</p>
<h3><span id="more-304"></span>Apple Script Code</h3>
<p>Make a new script and copy it to your ~/Library/Scripts folder.</p>
<pre class="brush: jscript;">
tell application &quot;Mail&quot;
	set junkCount to unread count of junk mailbox as number
	set inboxCount to unread count of inbox as number

	(* this returns a count of all the messages in the inbox *)
	set inboxMsgs to count messages of inbox

	(* this returns only the unread count of the inbox *)
	set total to 0
	repeat with mb in mailboxes
		set total to total + (unread count of mb) as number
	end repeat

	(* this will count all the messages *)
	(*
	set mailboxMsgs to 0
	repeat with mb in mailboxes
		set mailboxMsgs to mailboxMsgs + (count messages of mb)
	end repeat
        *)

	if inboxMsgs &gt; 0 then
		set sn to junkCount / (inboxMsgs + junkCount) as number
	else
		set sn to 0
	end if

	(* establish the baseline value for the meter *)
	if sn &lt; 0.3 then
		set sn to 0.3
	end if

	(*
	display dialog (&quot;Signal to Noise - &quot; &amp; sn)
	*)

end tell

set portName to (item 1 of (serialport list))
set portRef to serialport open portName bps rate 9600
if portRef is equal to -1 then

	display dialog &quot;Could not open Serial Port: &quot; &amp; portName

else
	delay 2
	set sendVal to 10 * sn as integer
	serialport write sendVal to portRef (* sn should be a ratio *)
	delay 3

	serialport close portRef
end if

(* this will list all the serial ports available *)
(*
serialport list
*)
</pre>
<h3>Arduino code</h3>
<p>This is for the meter, specifically, but could be easily updated for other output devices.</p>
<pre class="brush: cpp;">
/*
  Signal / noise meter
  2009 Robert Carlsen // robertcarlsen.net

  driving a mechanical decibel meter with PWM via Arduino

  raw analogWrite values:
  3 : -4 (bottom of scale)
  9 : +6 (top of scale)

  draws about 1mA at top of scale

  running through an LED and 220ohm resistor to provide more load
  and to protect the Arduino from (possible) reverse current as the
  springs pull the needle past the electromagnet when it's turned off
 */

int meterPin = 3;
byte val;

int maxVal = 40; // this is adjusted for the load of the meter, resistor and led

int inputMode = 0;
int numModes = 3;

void setup() {
  pinMode(meterPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){

  if(Serial.available()){
    val = Serial.read();
    Serial.flush();

    // change modes
    if(val == 255){
      inputMode = (inputMode + 1) % numModes;
      val = 0;
      return;
    }

    // allow mode switching. default is to accept ascii 0-9
    // second mode is to accept raw bytes 0-254
    // third mode echos the received values for testing
    switch(inputMode){
    case 0: // direct input from Serial Monitor
      // converting ascii values to int for math
      val = constrain(val,48,57) - 48;
      // mapping to a useable range
      val = map(val,0,9,0,maxVal);
      break;
    case 1: // input bytes
      // reserve 255 for changing mode
      val = map(val,0,254,0,maxVal);
      break;
    case 2: // monitor input values
      Serial.print(val , DEC);
      break;
    }
  }

  // send value:
  if(inputMode != 2)
  analogWrite(meterPin, (int)val); 

  delay(100);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/01/16/signal-to-noise-meter-mail-304/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(Signal to) Noise meter, ITP 4in4, day 4</title>
		<link>http://robertcarlsen.net/2009/01/15/signal-to-noise-meter-itp-4in4-day-4-296</link>
		<comments>http://robertcarlsen.net/2009/01/15/signal-to-noise-meter-itp-4in4-day-4-296#comments</comments>
		<pubDate>Thu, 15 Jan 2009 20:15:27 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[itp]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[4in4]]></category>
		<category><![CDATA[analog]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[meter]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[visualizing]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=296</guid>
		<description><![CDATA[For today&#8217;s project I wanted to do something with the analog decibel meter that Tymm gave me on day one. My idea is to calculate some kind of signal to noise ratio in my email inbox and to display the value on this physical meter. Since I already get a lot of noise in there, [...]]]></description>
			<content:encoded><![CDATA[<p>For today&#8217;s project I wanted to do something with the analog decibel meter that Tymm gave me on day one. My idea is to calculate some kind of signal to noise ratio in my email inbox and to display the value on this physical meter. Since I already get a lot of noise in there, maybe the value won&#8217;t change very dynamically, but be a steady din. Perhaps I could tie into the junk mail filter to show just how much work it&#8217;s doing, like a tachometer. Who am I kidding, really, I&#8217;m likely going to jump into what all the cool kids are doing and just come up with some type of Twitter visualization&#8230;  <span id="more-296"></span></p>
<p>Regardless of the data source, for the output side I&#8217;m driving the analog decibel meter with an Arduino using pulse width modulation (PWM). Inside it seems to be a small electromagnet whose field moves the needle to the right. The movement is counteracted by several springs which keep the needle trying to pull back to the left.</p>
<p>It seems to take minimal current &lt; 1mA at 5V to peg the needle. The face of the meter indicates &#8220;1mW 600 Ohm&#8221; which I assume means that the max input is 1mW and the resistance of the unit is 600Ohm. (Please correct me if I&#8217;m wrong). I&#8217;ve installed a 220Ohm resistor and small LED in series to provide more load to the PWM pin which allows finer steps in the meter as well as protects the Arduino from any possible reverse current as the needle&#8217;s springs pull it back past the electromagnet. I likely don&#8217;t need that, but it wouldn&#8217;t be an ITP project without an LED (it&#8217;s not blinking, though).</p>
<p>In this demo the Arduino is receiving data via a serial connection from a simple Processing sketch to control the position of the needle. In the above mentioned configuration I&#8217;m mapping the input value to a PWM output range of 0-40. Sending byte 255 will change modes in the program. The default mode is to accept ASCII values of 48-52 (that&#8217;s 0-9) so I can test in a terminal. The second mode will accept all bytes bytes of 0-254, and the third mode simply reports back the received values.</p>
<p>Next step is to figure out exactly what to do with the meter; since it accepts serial data it is pretty modular.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/T_784yakuvc&#038;fs=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/T_784yakuvc&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/01/15/signal-to-noise-meter-itp-4in4-day-4-296/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meggy pixel video display. 4-in-4, day one.</title>
		<link>http://robertcarlsen.net/2009/01/13/meggy-pixel-video-display-4-in-4-day-one-280</link>
		<comments>http://robertcarlsen.net/2009/01/13/meggy-pixel-video-display-4-in-4-day-one-280#comments</comments>
		<pubDate>Tue, 13 Jan 2009 09:40:58 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[itp]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[4in4]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[meggy]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=280</guid>
		<description><![CDATA[Spent most of the day at Tymm&#8217;s house, pretending to participate in 4-in-4, but mostly drinking coffee and watching videos. I did eventually get around to tinkering with my new Meggy Jr RGB from Evil Mad Scientist Laboratories. The Meggy is a pixel game platform built around a vivid 8&#215;8 LED matrix running an Arduino [...]]]></description>
			<content:encoded><![CDATA[<p>Spent most of the day at Tymm&#8217;s house, pretending to participate in <a href="http://itp.nyu.edu/ITPedia/4in4" onclick="pageTracker._trackPageview('/outgoing/itp.nyu.edu/ITPedia/4in4?referer=');">4-in-4</a>, but mostly drinking coffee and watching videos. I did eventually get around to tinkering with my new Meggy Jr RGB from <a href="http://www.evilmadscientist.com/" onclick="pageTracker._trackPageview('/outgoing/www.evilmadscientist.com/?referer=');">Evil Mad Scientist Laboratories</a>. The Meggy is a pixel game platform built around a vivid 8&#215;8 LED matrix running an Arduino compatible ATMega168. EMSL has also released a simple to use library for managing the display, buttons and speaker. It&#8217;s really a great kit.</p>
<p>I decided to ignore all the nice easy stuff <span id="more-280"></span>and get right to speaking to the Meggy&#8217;s frame buffer, a 192 byte long array containing the values for each RGB pixel. I wrote up a Processing sketch on a MacBook Pro to capture a video image, scale it to 8&#215;8, format the image in a Meggy framebuffer style array and send the whole thing via serial. The most challenging part was figuring out the framebuffer format, which although documented by EMSL was difficult for me to work out initially.</p>
<p>Also, the colors are not correct on the first try, and the RGB elements respond with different brightnesses than each other. The source code from the Meggy library provided some insight on suitable adjustment levels, which the Processing script is doing before sending along the pixel values. Fun times&#8230;enjoy the video (may help to squint at the pixels)! Code below the video.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/y2YkYOLgppY&#038;fs=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed src="http://www.youtube.com/v/y2YkYOLgppY&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<h3>Arduino code:</h3>
<pre class="brush: cpp;">
/*
  MeggyJr_VideoDisplay
 2009 Robert Carlsen // robertcarlsen.net

 Accepts serial data of a video stream from a desktop counterpart
 Expects a header byte of 128, then 192 bytes of pixel data (&lt;= 127)
*/

#include &lt;MeggyJr.h&gt;
MeggyJr Meg;

// stores how many bytes have been received for the current frame:
byte index = 0;

void setup()
{
  Meg = MeggyJr();    // Required.
  Serial.begin(57600);
}  

void loop()
{
  // check if data has been sent from the computer:
  if (Serial.available()) {
    // read in the current byte:
    byte val = Serial.read();

    // look for the header:
    if(val == 128){
      // the header byte was found, the beginning of a new frame in next:
      index = 0;
      return;
    }

    // write the current info directly to the MeggyFrame buffer
    // this may cause tearing or other artifacts...please clean up if you like <img src='http://robertcarlsen.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
    // the frame data has been packed in the expected order by the sender program
    // also, only the low four bits are used for pixel color. &quot;&amp; 0x0F&quot;  masks them.
    // i'm thinking of packing other data, such as vertical blanking
    // pixel index or &quot;timecode&quot; in the high bits.
    Meg.MeggyFrame[index] = val &amp; 0x0F;
    index++;
  }

  // don't really need a delay here
  // delay(7);
}
</pre>
<h3>Processing sketch:</h3>
<pre class="brush: java;">
/*
  MeggyVideoSend
  2009 Robert Carlsen // robertcarlsen.net

  Captures the video camera image, downsamples it to 8x8
  and packs the pixel data in a format compatible with the Meggy Jr RGB.
  Finally, send the pixel data to the Meggy

  Requires the complementary MeggyJr_Video firmware loaded on the Meggy
*/

import processing.video.*;
import processing.serial.*;

Serial myPort;  // Create object from Serial class
Capture myCapture; // set up a video capture object

// the LEDs respond with varied brightness.
// this adjustment will color correct them.
// feel free to experiment.
float[] adj = {0.6,1.0,0.5}; // red,green,blue

void setup() {
  size(300,300);

  // open a serial port to the Meggy. you may need to change the 0. check the list in the console.
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 57600);

  // start a video capture:
  myCapture = new Capture(this, 8, 8, 30);

  // if you have trouble with the above, uncomment the below and replace &quot;Camera Name&quot; with the appropriate device.
  // println(Capture.list());
  // myCapture = new Capture(this, width, height, &quot;Camera Name&quot;, 30);
}

void draw() {
  // create an array for the pixel data:
  // one header byte and 192 bytes for pixels (64 pixels * 3 bytes / pixel)
  byte[] c = new byte[193];

  // read the pixels from the video capture:
  myCapture.loadPixels();

  // header byte:
  c[0] = (byte)128;

  // loop through all the pixels in the video image
  // adjust the colors and pack the bytes in the correct order:
  for(int i = 0; i &lt; 64; i++){
    // adjust colors:
    // for an explanation of what's going on, look up &quot;bit shifting&quot; on the Processing site.
    int r = (int)(adj[0]*((myCapture.pixels[i]&gt;&gt;16) &amp; 0xFF));
    int g = (int)(adj[1]*((myCapture.pixels[i]&gt;&gt;8) &amp; 0xFF));
    int b = (int)(adj[2]*((myCapture.pixels[i]) &amp; 0xFF));

    // the Meggy expects 0-15 values only.
    // right shift &quot;&gt;&gt;4&quot; essentially divides our 8-bit values in Processing (0-255) by 16 giving a range of 0-15.
    // the Meggy packs the pixels into a long array, similar to the pixels in Processing.
    // however, each pixel is stored in 3 separate bytes rather than one big integer.
    // the (messy) conversion is below. we're also adding 1 to the index to account for the header byte.
    c[24*(i/8)+i%8+17] = (byte)(r&gt;&gt;4); // r: index + 16
    c[24*(i/8)+i%8+9] = (byte)(g&gt;&gt;4); // g: index + 8
    c[24*(i/8)+i%8+1] = (byte)(b&gt;&gt;4);  // b: index
  }

  // send the whole frame data out via serial:
  myPort.write(c);

  // draw the current frame to the computer screen for preview:
  image(myCapture,0,0,width,height);
}

// read in a new frame of video if available:
void captureEvent(Capture myCapture) {
  myCapture.read();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/01/13/meggy-pixel-video-display-4-in-4-day-one-280/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>meggy! MEGGY! (and nyc resistor)</title>
		<link>http://robertcarlsen.net/2009/01/09/meggy-meggy-and-nyc-resistor-261</link>
		<comments>http://robertcarlsen.net/2009/01/09/meggy-meggy-and-nyc-resistor-261#comments</comments>
		<pubDate>Fri, 09 Jan 2009 18:01:48 +0000</pubDate>
		<dc:creator>Robert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[brooklyn]]></category>
		<category><![CDATA[evil mad science]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[meggy]]></category>
		<category><![CDATA[nyc]]></category>
		<category><![CDATA[nyc resistor]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=261</guid>
		<description><![CDATA[nyc resistor had one of their craft nights last evening, where they invite folks to come in to work on just about anything &#8220;so you don&#8217;t have to make stuff by yourself.&#8221; i had been missing my community fix now that ITP is on winter break, so heading over there to assemble my new meggy [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/01/dsc03185.jpg" rel="lightbox[261]"><img class="size-medium wp-image-262 alignleft" style="margin: 3px;" title="meggy board" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/01/dsc03185-300x225.jpg" alt="meggy board" width="300" height="225" /></a><a href="http://www.nycresistor.com/" onclick="pageTracker._trackPageview('/outgoing/www.nycresistor.com/?referer=');">nyc resistor</a> had one of their craft nights last evening, where they invite folks to come in to work on just about anything &#8220;<span class="event-description">so you don&#8217;t have to make stuff by yourself.&#8221; i had been missing my community fix now that ITP is on winter break, so heading over there to assemble my new meggy jr rgb kit from <a href="http://www.evilmadscientist.com/" onclick="pageTracker._trackPageview('/outgoing/www.evilmadscientist.com/?referer=');">evil mad scientist</a> seemed like the things to do.<span id="more-261"></span></span></p>
<p>the space is a pretty comfortable workshop in a loft building in downtown brooklyn. it reminded me a lot of my old studio in philly&#8230;i was getting nostalgic. the folks there were nice&#8230;it was generally pleasant to work quietly and listen to the various conversation topics being discussed. people would look over your shoulder and ask what you were working on. fun times had by all.</p>
<p>the meggy jr rgb is a kit from evil mad science laboratories&#8230;kind of a handheld smaller sibling of their peggy kit. it&#8217;s driven by an atmel atmega168 and they&#8217;ve released an arduino-based library for programming the 8&#215;8 rgb led matrix&#8230;super simple drawPx(3,4, Red); how can you beat that? the included (paper) instructions were very clear, with lots of photos&#8230;super for a hobbyist (like me). after getting settled, and despite taking pauses to chat with folks i had the kit built in about 2 hours.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2009/01/dsc03187.jpg" rel="lightbox[261]"><img class="alignright size-medium wp-image-263" style="margin: 3px;" title="meggy assembled" src="http://robertcarlsen.net/blog/wp-content/uploads/2009/01/dsc03187-300x225.jpg" alt="meggy assembled" width="300" height="225" /></a>the game provided on the microcontroller is a defender-like side scrolling shooter dubbed &#8220;attack of the cherry tomatoes&#8221;, which i&#8217;d assume is named for the killer red leds which continually advance across the screen. it&#8217;s surprisingly engaging and everyone who tried it thought the same. the display is also very vivid&#8230;lots of fun.</p>
<p>i&#8217;m considering using the <a href="http://itp.nyu.edu/ITPedia/4in4" onclick="pageTracker._trackPageview('/outgoing/itp.nyu.edu/ITPedia/4in4?referer=');">4-in-4 event</a> to write four games for it. although i just had a thought that maybe i&#8217;ll write four programs for four platforms, now that i have my iphone developer certificate&#8230;hmm. 1. meggy, 2. iphone, 3. desktop&#8230; ??? 4. profit! (i hope the joke is well received) <img src='http://robertcarlsen.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2009/01/09/meggy-meggy-and-nyc-resistor-261/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>elmo hacking</title>
		<link>http://robertcarlsen.net/2008/12/14/elmo-hacking-241</link>
		<comments>http://robertcarlsen.net/2008/12/14/elmo-hacking-241#comments</comments>
		<pubDate>Sun, 14 Dec 2008 16:14:07 +0000</pubDate>
		<dc:creator>Robert Carlsen</dc:creator>
				<category><![CDATA[make]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[elmo]]></category>
		<category><![CDATA[eyebeam]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[holiday]]></category>
		<category><![CDATA[nyc]]></category>
		<category><![CDATA[xbee]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=241</guid>
		<description><![CDATA[this saturday i participated in the elmo hacking workshop at eyebeam. adrianne wortzel , a resident at eyebeam, has a project which involves synchronizing the movements of 50 tickle-me elmos. mike gazes and soyoung park realized adrianne&#8217;s idea by reverse engineering the elmo&#8217;s and creating a new control unit based around an atmel atmega168, using [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking1.jpg" rel="lightbox[241]"><img class="alignleft alignnone size-medium wp-image-246" style="border: 1px solid black; margin: 3px; float: left;" title="elmo_hacking1" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking1-300x225.jpg" alt="" width="236" height="177" /></a>this saturday i participated in the elmo hacking workshop at eyebeam. adrianne wortzel , a resident at eyebeam, has a <a href="http://www.adriannewortzel.com/eyebeam/Project/index.html" onclick="pageTracker._trackPageview('/outgoing/www.adriannewortzel.com/eyebeam/Project/index.html?referer=');">project</a> which involves synchronizing the movements of 50 tickle-me elmos. mike gazes and soyoung park realized adrianne&#8217;s idea by reverse engineering the elmo&#8217;s and creating a new control unit based around an atmel atmega168, using the arduino development environment. wireless communication is through xbee radios (so many <span id="more-241"></span>of them).</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking3.jpg" rel="lightbox[241]"><img class="alignright alignnone size-medium wp-image-244" style="border: 1px solid black; margin: 3px; float: right;" title="elmo_hacking3" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking3-300x225.jpg" alt="" width="251" height="189" /></a>anyway, i went to meet the team last week and was introduced to the project, and yesterday during the holiday hackshop a bunch of dedicated volunteers deconstructed elmos, burned microchips and built the circuit boards. although we didn&#8217;t get all 50 built, we made great progress in getting the elmo army constructed&#8230;.and saw the first live demo of 9 working together.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking3.jpg" rel="lightbox[241]"><img class="alignleft alignnone size-medium wp-image-244" style="border: 1px solid black; margin: 3px; float: left;" title="elmo_hacking3" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking2.jpg" alt="" width="259" height="195" /></a>it was a great time, and the first time i&#8217;d been to eyebeam when it was open to the public. i missed out on the other workshops as i focused on soldering away. the experience of having to build many identical custom boards will definitely inform future projects. i realize now what the socialbomb kids were talking about when describing the process of creating the devices for their game&#8230;</p>
<p>I&#8217;ll be looking forward to the actual performance of the elmos at some point&#8230;</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking5.jpg" rel="lightbox[241]"><img class="alignnone size-medium wp-image-242" style="border: 1px solid black; margin: 3px; float: left;" title="elmo_hacking5" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking5-300x225.jpg" alt="" width="268" height="201" /></a></p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking4.jpg" rel="lightbox[241]"><img class="alignnone size-medium wp-image-243" style="border: 1px solid black; margin: 3px; float: left;" title="elmo_hacking4" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/12/elmo_hacking4-225x300.jpg" alt="" width="225" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2008/12/14/elmo-hacking-241/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>next step&#8230;the world!</title>
		<link>http://robertcarlsen.net/2008/11/13/next-stepthe-world-221</link>
		<comments>http://robertcarlsen.net/2008/11/13/next-stepthe-world-221#comments</comments>
		<pubDate>Fri, 14 Nov 2008 00:59:50 +0000</pubDate>
		<dc:creator>Robert Carlsen</dc:creator>
				<category><![CDATA[Intro to Physical Computing]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[itp]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=221</guid>
		<description><![CDATA[i got around to working directly with the Arduino&#8217;s microchip, the ATmega168, and built my first Arduino on a breadboard. part of the reason is cost&#8230;an Arduino Diecimila is $30, even the Barebones Arduino and similar clones are about $15. A raw ATmega168 chip is about $4, and the remaining parts (sans breadboard) are about [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/11/dsc02882.jpg" rel="lightbox[221]"><img class="alignright alignnone size-medium wp-image-223" style="float: right; margin-left: 5px; margin-right: 5px;" title="dsc02882" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/11/dsc02882-300x225.jpg" alt="" width="230" height="172" /></a>i got around to working directly with the Arduino&#8217;s microchip, the ATmega168, and built my first Arduino on a breadboard. part of the reason is cost&#8230;an Arduino Diecimila is $30, even the Barebones Arduino and similar clones are about $15. A raw ATmega168 chip is about $4, and the remaining parts (sans breadboard) are about $3 &#8211; so for $7 i can build a circuit around the Arduino&#8217;s chip and use the same programming environment.</p>
<p>the main reason to do this is flexibility. i can build ad hoc prototype circuits for individual projects relatively cheaply. also, if i fry a microcontroller it&#8217;s just a simple matter to swap it for a new one (which is also true of the packaged Arduino variants.<span id="more-221"></span></p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/11/dsc02879.jpg" rel="lightbox[221]"><img class="alignleft alignnone size-medium wp-image-224" style="float: left; margin-left: 5px; margin-right: 5px;" title="dsc02879" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/11/dsc02879-300x225.jpg" alt="" width="218" height="163" /></a>i wanted to get experience burning bootloaders on raw chips, which then enables them to have new programs loaded easily over usb, typically using the Arduino development software. although we have chip programmers available at ITP, i wanted to try a <a href="http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html" onclick="pageTracker._trackPageview('/outgoing/www.geocities.jp/arduino_diecimila/bootloader/index_en.html?referer=');">documented</a> <a href="http://www.arduino.cc/playground/Hacking/AvrdudeFTDIBitbang" onclick="pageTracker._trackPageview('/outgoing/www.arduino.cc/playground/Hacking/AvrdudeFTDIBitbang?referer=');">method</a> for using a modified Diecimila board directly to bootload new chips using the &#8220;bit bang&#8221; capability of the FTDI USB-Serial chip.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/11/burning-bootloader.jpg" rel="lightbox[221]"><img class="alignright size-medium wp-image-225" title="burning-bootloader" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/11/burning-bootloader-300x167.jpg" alt="" width="241" height="134" /></a>the modification was pretty easy, and although manual (and windows-only) the avrdude-serjtag software was trouble free &#8211; at least when following instructions step-by-step. i successfully burned four new ATmega chips then uploaded the basic blink sketch to each.</p>
<p>i set up a breadboard following ITP&#8217;s notes, added a USB chip and uploaded some sketches. let me know if you can read the message in the below video <img src='http://robertcarlsen.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img src="http://robertcarlsen.net/blog/wp-content/plugins/flash-video-player/default_video_player.gif" /></p>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2008/11/13/next-stepthe-world-221/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>skull control (via serial)</title>
		<link>http://robertcarlsen.net/2008/10/01/skull-control-via-serial-161</link>
		<comments>http://robertcarlsen.net/2008/10/01/skull-control-via-serial-161#comments</comments>
		<pubDate>Wed, 01 Oct 2008 07:16:59 +0000</pubDate>
		<dc:creator>Robert Carlsen</dc:creator>
				<category><![CDATA[Intro to Physical Computing]]></category>
		<category><![CDATA[itp]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[halloween]]></category>
		<category><![CDATA[pcom]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[serial]]></category>

		<guid isPermaLink="false">http://robertcarlsen.net/blog/?p=161</guid>
		<description><![CDATA[Started up working with basic motor control, ended up hacking into an existing Halloween candy bowl talking skull.


Back to the beginning – controlling a motor with the Arduino. So, the first step was getting acquainted with transistors to isolate the microcontroller&#8217;s power supply from the motor&#8217;s. The TIP120 is simple to use, if frustratingly similar [...]]]></description>
			<content:encoded><![CDATA[<p>Started up working with basic motor control, ended up hacking into an existing Halloween candy bowl talking skull.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/holding_skull.jpg" rel="lightbox[161]"><img class="alignnone size-medium wp-image-162" title="holding_skull" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/holding_skull-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><span id="more-161"></span></p>
<p>Back to the beginning – controlling a motor with the Arduino. So, the first step was getting acquainted with transistors to isolate the microcontroller&#8217;s power supply from the motor&#8217;s. The TIP120 is simple to use, if frustratingly similar looking to the 7805 power regulator. Below is a pic of the circuit for simple variable speed motor control. There is no H bridge here, so the motor only spins in one direction. The blue wire goes to the Arduino pin (digital PWM), red/black to the motor and +5v/transistor and the other black wire connects the transistor to ground. Base -&gt; microcontroller, Collector -&gt; motor, Emitter -&gt; ground.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/dc_motor_transistor.jpg" rel="lightbox[161]"><img class="alignnone size-medium wp-image-165" title="dc_motor_transistor" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/dc_motor_transistor-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Doing this allows the circuit to have separate power for the motor&#8230;which can just barely be powered adequately by the Arduino directly. Running it off a 9V wall wart (through a 5V regulator) performs much better. Even a 9V battery works ok. (ignore the resistors on the breadboard below&#8230;they are a resistor ladder from a previous experiment)</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/dc_motor_battery.jpg" rel="lightbox[161]"><img class="alignnone size-medium wp-image-167" title="dc_motor_battery" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/dc_motor_battery-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Once the basic control was established, it was pretty simple to read a flex sensor and use it to control the speed of the motor.</p>
<p><img src="http://robertcarlsen.net/blog/wp-content/plugins/flash-video-player/default_video_player.gif" /></p>
<p>There has been talk of an ITP Haunted House for Halloween this year&#8230;which got me thinking about hacking the plethora of toys available. I found a great talking skull candy bowl at a department store across Broadway from school. It has a piezo and a photodiode sensor for detecting movement and light change. It also had an on/off switch and another switch that turned enabled the sensors.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/skull_overview.jpg" rel="lightbox[161]"><img class="alignnone size-medium wp-image-164" title="skull_overview" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/skull_overview-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The mechanics of the motors and movement seemed solid and I didn&#8217;t want to mess with that. However, I thought that it would be neat to extend control of the device to an external interface. The result is that I&#8217;ve spliced transistors into the switches of the toy&#8217;s existing circuit.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/skull_transistors.jpg" rel="lightbox[161]"><img class="alignnone size-medium wp-image-170" title="skull_transistors" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/skull_transistors-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>The Arduino can be controlled via serial commands and will also report the status of switches. I also threw in a timer function to trigger the skull at a set interval. Here&#8217;s an early demo of the control:</p>
<p><img src="http://robertcarlsen.net/blog/wp-content/plugins/flash-video-player/default_video_player.gif" /></p>
<p>I&#8217;d like to have some kind of network interface for controlling this&#8230;it would be neat for some physically distant event to trigger the skull. For the meantime I have a Processing sketch as a visual interface to the serial commands.</p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/control_interface.jpg" rel="lightbox[161]"><img class="alignnone size-medium wp-image-163" title="control_interface" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/control_interface-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><a href="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/skullinterface.jpg" rel="lightbox[161]"><img class="alignnone size-medium wp-image-166" title="skullinterface" src="http://robertcarlsen.net/blog/wp-content/uploads/2008/10/skullinterface-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>Arduino code:</p>
<pre>// hacking the skull toy
/*
the toy has a piezo and photodiode for activting it
there is also a momentary switch for turning it on and off

there are two motors, two LEDs and a speaker all driven by an IC

it is operated by about 4.5V (three AA batteries) and seems to draw up to 1A - usually 800mA.
can run it off a 9V wall wart through a 7508 regulator, although the heat sink gets really hot

there is a switch to enable the sensors.

thinking of overriding ond of the sensors to enable the microcontroller to activate the toy
*/

int switchPin = 2;
int timedFlag = 0;

int speakerPin = 3;
int speakerFlag = 1;

int sensorsPin = 4;
int sensorsFlag = 0;

static int TIMER_DUR = 15000;

long timer;

void setup(){
Serial.begin(9600);
pinMode(switchPin,OUTPUT);
pinMode(sensorsPin,OUTPUT);
pinMode(speakerPin,OUTPUT);
}

void loop(){
int var = digitalRead(switchPin);

if(timedFlag == 1){
if(millis() - timer &gt; TIMER_DUR){
digitalWrite(switchPin, HIGH);
// Serial.println("Switch went high");
delay(20);
digitalWrite(switchPin,LOW);
// Serial.println("Switch went low");
timer = millis();
}
}

if(Serial.available()&gt;0) {
int incoming = Serial.read();

switch(incoming){
case 'a':
Serial.println(var);
break;
case 's':
if(sensorsFlag == 0){
sensorsFlag = 1;
// Serial.println("Sensors on");
}
else {
sensorsFlag = 0;
// Serial.println("Sensors off");
}
digitalWrite(sensorsPin,sensorsFlag);
break;
case 't':
if(timedFlag == 0){
timedFlag = 1;
// Serial.println("Timer on");
}
else {
timedFlag = 0;
// Serial.println("Timer off");
}
break;

case 'r':
// send status report:
// Human readable:
/*
Serial.print("Sensors: ");
Serial.println(sensorsFlag);
Serial.print("Speaker: ");
Serial.println(speakerFlag);
Serial.print("Timer Flag: ");
Serial.println(timedFlag);
Serial.print("Timer: ");
Serial.println(millis()-timer);
*/

// for talking to Processing
Serial.print(sensorsFlag,BYTE);
Serial.print(speakerFlag,BYTE);
Serial.print(timedFlag,BYTE);
Serial.print(0,BYTE);
break;

case 'o':
// toggle on/off
digitalWrite(switchPin, HIGH);
delay(30);
digitalWrite(switchPin,LOW);
//Serial.println("On/Off toggled");
break;

case 'm':
// toggle the speaker
if(speakerFlag == 0){
speakerFlag = 1;
//Serial.println("Speaker on");
}
else {
speakerFlag = 0;
//Serial.println("Speaker off");
}
digitalWrite(speakerPin,speakerFlag);
break;

}
}

}</pre>
<p>And the Processing code:</p>
<pre>import processing.serial.*;

// control the skull via serial
// 2008 r. carlsen

/*
// call/response:
 Send 'r' (report)
 Sensors: 0|1
 Speaker: 0|1
 Timer Flag: 0|1
 Timer: long

 's' toggles sensors
 'o' immediately toggles on/off
 'm' toggles the speaker
 't' toggles the 15 second timer

 */

PFont font;
Serial myPort;
String inString;    // Incoming serial data
int skullStatus[] = new int[4];
float margin = 75;

boolean firstRun = true;

float buttonLoc[][] = new float [4][4]; // l,t,r,b

void setup() {
  size(500,150);

  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);

  font = createFont("SansSerif",18);
  textFont(font);
}

void draw() {
  background(102);

  // query the device and wait for the arduino to initialize
  if(firstRun){
    if(millis() &gt; 2000){
      getReport();
      firstRun =false;
    }
    else {
      // silly label
      textAlign(RIGHT);
      textSize(10);
      fill(204);
      text("[loading...]", width-15,15);
    }
  }

  for(int i=0;i&lt;4;i++){
    // query the status

    int curData = skullStatus[i];

    float x = lerp(margin,width-margin,i/3f);
    float y = height/2 - 10;

    fill(map(curData,0,1,50,255));
    stroke(0);

    rectMode(CENTER);
    rect(x,y,margin,margin);

    buttonLoc[i][0] = x-margin/2;
    buttonLoc[i][1] = y-margin/2;
    buttonLoc[i][2] = x+margin/2;
    buttonLoc[i][3] = y+margin/2;

    // display labels
    fill(204);
    textFont(font);
    textAlign(CENTER);
    String label;

    switch(i){
    case 0:
      label = "Sensors";
      break;
    case 1:
      label = "Speaker";
      break;
    case 2:
      label = "Timer";
      break;
    default:
      label = "On/Off";
      break;
    }

    text(label,x,y+65);
  }

  // silly label
  textAlign(LEFT);
  textSize(10);
  fill(204);
  text("skull control | v0.01 | oct 2008 | r.carlsen", 15,15);

}

void serialEvent(Serial myPort) {
  // now assuming 4 byte messages
  // sensors|speaker|timer|unused
  if(myPort.available() &gt; 3){
    inString = myPort.readString();
    //println(inString);
    for(int i=0;i&lt;inString.length();i++){
      skullStatus[i] = int(inString.charAt(i));
    }
    //println(skullStatus);
  }
}

void keyPressed(){
  switch(key){
  case 's':
  case 'o':
  case 'm':
  case 't':
    myPort.write(key);
    getReport();
    break;
  case 'r':
    getReport();
    break;
  }
}

void mousePressed() {
  for(int i=0;i&lt;buttonLoc.length;i++){
    if(mouseX&gt;=buttonLoc[i][0] &amp;&amp; mouseY &gt;= buttonLoc[i][1] &amp;&amp; mouseX &lt;= buttonLoc[i][2] &amp;&amp; mouseY &lt;= buttonLoc[i][3]){
      // we've been pressed!

      //println("button pressed!");

      switch(i){
      case 0:
        // sensors
        myPort.write('s');
        break;
      case 1:
        // mute
        myPort.write('m');
        break;
      case 2:
        // timer
        myPort.write('t');
        break;
      case 3:
        // on/off
        myPort.write('o');
        break;
      }
      // update the status report
      getReport();
    }
  }
}

void getReport() {
  // request report
  myPort.write('r');

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://robertcarlsen.net/2008/10/01/skull-control-via-serial-161/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
