<?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>BIT-101</title>
	<atom:link href="http://www.bit-101.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.bit-101.com/blog</link>
	<description>Showing electrons who is boss.</description>
	<lastBuildDate>Wed, 29 May 2013 18:35:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Simple Arduino Motor Control</title>
		<link>http://www.bit-101.com/blog/?p=3831</link>
		<comments>http://www.bit-101.com/blog/?p=3831#comments</comments>
		<pubDate>Wed, 29 May 2013 17:19:31 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[Physical Computing]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3831</guid>
		<description><![CDATA[Send to Kindle One thing you might want to do with an Arduino or even a Raspberry Pi is control a motor. Of course, the GPIO pins on this board are really just designed to send and receive informational signals, not drive the load of something that&#8217;s going to draw any significant current like a [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_001.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_001-300x168.jpg" alt="WP_20130529_001" width="300" height="168" class="alignnone size-medium wp-image-3837" /></a></p>
<p>One thing you might want to do with an Arduino or even a Raspberry Pi is control a motor. Of course, the GPIO pins on this board are really just designed to send and receive informational signals, not drive the load of something that&#8217;s going to draw any significant current like a motor. An LED is fine, but much beyond that and you really need to look at a different solution.</p>
<p>I simply wanted to control a motor from my Arduino. I have a little hobby motor. I measured that at 3 volts it draws 150 mA (milliAmps). The Arduino&#8217;s GPIO pins are rated at around 40 mA. So that wasn&#8217;t going to cut it. I know there are various motor controller shields that you can hook up to your Arduino for this purpose, but I didn&#8217;t think I needed to go that route. Those boards offer a lot of functionality and are great if you have a specific project in mind and need all that control without going through the hassle of figuring out how to do it. But they are also the very definition of a &#8220;black box&#8221;. You put some input into them and get some input out of them. There&#8217;s all kinds of components and chips and traces on the boards, so you don&#8217;t really have any idea what&#8217;s going on between the input and output.</p>
<div id="attachment_3839" class="wp-caption alignnone" style="width: 310px"><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_003.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_003-300x168.jpg" alt="150 mA - too high for Arduino&#039;s GPIO" width="300" height="168" class="size-medium wp-image-3839" /></a><p class="wp-caption-text">150 mA &#8211; too high for Arduino&#8217;s GPIO</p></div>
<p>For me, it was far more important to know exactly what was going on at this stage. So I grabbed a breadboard, some components and wire, and got busy. </p>
<p>All you really need is a transistor, a resistor and a separate power supply for the motor. I&#8217;m not going to go into a deep explanation of transistors, because there are about 73 million deep discussions about them on the net. Basically, it&#8217;s an electronic switch with three leads called the emitter, base, and collector. You put the emitter/collector combo between the external power and your load, in this case a motor. By default, it acts as an open switch, so the motor does not run. But when you supply a small current between the base and emitter, this &#8220;closes the switch&#8221;, allowing the current to flow from collector to emitter, and your motor runs!</p>
<p>The important thing is that it only takes a very small control signal at the base to allow a much larger current to flow through the emitter/collector. So you can use the GPIO output signals to control the transistor, and use a separate power supply to control the motor itself without taxing your delicate little Arduino.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_002.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_002-300x168.jpg" alt="WP_20130529_002" width="300" height="168" class="alignnone size-medium wp-image-3838" /></a></p>
<p>The transistor I used is a PN2222 series. These are very common, general use transistors. You can get 10 of them for under $2. I checked the data sheet for this transistor and found it can handle a maximum of around 50-60 volts on the emitter/collector. (There are a few different varieties of these, so I&#8217;m just reporting averages.) So my 3 volt motor should be fine. It can also handle a peak load of 1 amp &#8211; again fine for my 150 mA motor. Motors do draw a lot more current when the first start, but this would allow me more than 6x the running current as a peak. The base/emitter voltage is around 5-6 volts max. The Arduino outputs are 5 volts, which is cutting it close, so I threw in a 1000 ohm resistor. This results in just a few milliamps being drawn from the GPIO pin, through the base of the transistor and back out the emitter.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/motorcontrol.png"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/motorcontrol.png" alt="motorcontrol" width="567" height="347" class="alignnone size-full wp-image-3844" /></a></p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/motorcontrol_bb.png"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/motorcontrol_bb-300x205.png" alt="motorcontrol_bb" width="300" height="205" class="alignnone size-medium wp-image-3850" /></a></p>
<p>Then I hooked up the motor to a separate 3 volt power supply, passing it through the emitter/collector. With this setup, when the GPIO pin I choose is HIGH, the motor will run. When it&#8217;s LOW, the motor will stop. Despite the motor drawing at least 150 mA, the Arduino&#8217;s GPIO pins will only be serving up <del datetime="2013-05-29T18:33:33+00:00">2-3 mA</del> <ins datetime="2013-05-29T18:33:33+00:00">about 4 mA by actual measurement</ins> &#8211; way below the 40 mA limit.</p>
<p>For software, I set up a simple sketch as follows:</p>
<pre>void setup() {
    pinMode(7, OUTPUT);
}

void loop() {
    digitalWrite(7, HIGH);
    delay(1000);
    digitalWrite(7, LOW);
    delay(1000);
}</pre>
<p>Obviously, I&#8217;m using GPIO pin 7 as an output. This will set it HIGH for one second, then low for one second, switching the motor on and off for that amount of time. And it works! And as far as I can tell, everything is within safe ranges.</p>
<p>So there you go. Of course, this isn&#8217;t going to give you all the features of a dedicated motor control shield, such as variable speed with pulse with modulation, multiple motors, forward/reverse, etc. But now you know exactly what&#8217;s going on and can build on it if you want. Or at least have some concept on what&#8217;s going on inside that fancy shield.</p>
<p>Of course, it goes without saying to be VERY careful when wiring up a circuit like this. You are hooking up an external power source to the same board that your Arduino is hooked up to. A wrong move and you could send electrons flooding into where they have no business being. That&#8217;s another advantage to using shields, which buffer the Arduino&#8217;s connections and add a layer of protection. But don&#8217;t worry too much. A little smoke won&#8217;t kill you. <img src='http://www.bit-101.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_004.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130529_004-300x168.jpg" alt="WP_20130529_004" width="300" height="168" class="alignnone size-medium wp-image-3852" /></a></p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3831</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pull-up and Pull-down Resistors</title>
		<link>http://www.bit-101.com/blog/?p=3813</link>
		<comments>http://www.bit-101.com/blog/?p=3813#comments</comments>
		<pubDate>Thu, 23 May 2013 01:52:49 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Physical Computing]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3813</guid>
		<description><![CDATA[Send to KindleWorking a lot with Raspberry Pi and Arduino stuff lately. The concept of pull-up and pull-down resistors came up quickly and confused me a little at first. So I thought I&#8217;d do a little demo of how they work and why they are needed. Doing this helped to clarify it for me, so [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p>Working a lot with Raspberry Pi and Arduino stuff lately. The concept of pull-up and pull-down resistors came up quickly and confused me a little at first. So I thought I&#8217;d do a little demo of how they work and why they are needed. Doing this helped to clarify it for me, so maybe it&#8217;ll help you too.</p>
<p>Common scenario. You want to set up something that reads an input of a GPIO pin. Say, you want to know when the user is pressing a switch. You set up a simple circuit like so:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_1.png"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_1.png" alt="circuit_1" width="679" height="487" class="alignnone size-full wp-image-3814" /></a></p>
<p>And here that is wired up:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130523_002.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130523_002-300x168.jpg" alt="WP_20130523_002" width="300" height="168" class="alignnone size-medium wp-image-3827" /></a></p>
<p>When you press the button, pin 25 goes high. No press, no high, must be low, right? Well, let&#8217;s see&#8230;</p>
<p>We&#8217;ll set up a simple Python script to read the status of pin 25:</p>
<pre>#! /usr/bin/python

import RPi.GPIO as GPIO
import time

PIN = 25

GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.IN)

while True:
        if GPIO.input(PIN) == GPIO.HIGH:
                print("pin is high")
                time.sleep(.1)
        else:
                print("pin is low")
                time.sleep(.1)</pre>
<p>When I run this, I get 20-30 lines saying pin 25 is high, then 20-30 saying it&#8217;s low, back and forth, without touching the button. Sure enough when I press the button, it stays high, but apparently the definition of &#8220;low&#8221; is not &#8220;not high&#8221;.</p>
<p>After too many years in the highly binary world of software programming, some of us delving into hardware may be surprised to learn that a lot of electronics operate on &#8220;tri-state logic&#8221; as opposed to simple binary. Here, an input can be high, low, or floating. In this particular circuit, high means connected to 3.3 volts, low means connected to ground, and floating means&#8230; neither or somewhere in between. Actually, due to the sensitive nature of tiny electronics, system components can pick up various signals that create slight fluctuations in what it is reading. It&#8217;s rarely if ever going to pick up exactly 0.000 volts just because it&#8217;s not connected to 3.3 volts. </p>
<p>So we need to force the issue and say, &#8220;Yo! You are LOW!&#8221; My first thought on how to do this would probably have been to do something like this:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_2.png"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_2.png" alt="circuit_2" width="650" height="520" class="alignnone size-full wp-image-3818" /></a></p>
<p>When the switch is in one position, pin 25 is connected directly to ground, sending it solidly low. When the switch is changed, it connects 25 to 3.3 volts, making it high. This will work just fine, but it&#8217;s a bit overengineered as it turns out.</p>
<p>How about if we go simpler and just connect pin 25 to ground and leave it that way, like so:</p>
<p>(Note: DO NOT ACTUALLY BUILD THIS CIRCUIT!)</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_3.png"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_3.png" alt="circuit_3" width="619" height="489" class="alignnone size-full wp-image-3820" /></a></p>
<p>Now, when the switch is open, pin 25 is undoubtedly low. But we have a problem that when you do hit the switch, you now have a short circuit directly between 3.3 volts and ground. Not good. Again, do not do this. The solution? Throw a resistor in there:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_4.png"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_4.png" alt="circuit_4" width="634" height="477" class="alignnone size-full wp-image-3821" /></a></p>
<p>And in the real world:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130523_003.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130523_003-300x168.jpg" alt="WP_20130523_003" width="300" height="168" class="alignnone size-medium wp-image-3829" /></a></p>
<p>Now, when the switch is open, pin 25 is connected to ground through the 10K resistor. Even with the resistor though, it&#8217;s enough of a connection to make it solidly low. It&#8217;s not going to fluctuate.</p>
<p>Then we hit the switch, connecting the lower part of the circuit to the 3.3 volts. Because we have a fairly high resistance there, most of the current is going to go to pin 25, sending it solidly high. Some of it is also going to go to ground via R1. But Ohm&#8217;s Law tells us that 3.3 volts divided by 10,000 ohms will let about 0.33 milliamps in. That&#8217;s not going to break the bank.</p>
<p>So in this circuit, R1 is called a pull-down resistor because in its default state it pulls the signal down to 0 volts or a low state. </p>
<p>Now let&#8217;s swap things around a bit:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_5.png"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/circuit_5.png" alt="circuit_5" width="670" height="484" class="alignnone size-full wp-image-3822" /></a></p>
<p>Now pin 25 is hard-wired to 3.3 volts through R1, making its default state high. However when the button is pressed, pin 25 will be directly connected to ground, sending it low. Because the resistor pulls pin 25 up to 3.3 volts and a high state, it&#8217;s now known as a pull-up resistor.</p>
<p>So, which one do you use? It depends on whether you want your default signal to be high or low.</p>
<p>Hope that helps.</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3813</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Raspberry Pi Mail Checker</title>
		<link>http://www.bit-101.com/blog/?p=3804</link>
		<comments>http://www.bit-101.com/blog/?p=3804#comments</comments>
		<pubDate>Tue, 21 May 2013 15:17:17 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3804</guid>
		<description><![CDATA[Send to Kindle I was looking for some Raspberry Pi project to do that not only used external hardware (even if that means only an LED for now), but also reached out into the net to deal with some kind of real time data. I ran into this tutorial on adafruit about checking your gmail [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130521_001.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130521_001-1024x576.jpg" alt="WP_20130521_001" width="512" height="283" class="alignnone size-large wp-image-3805" /></a></p>
<p>I was looking for some Raspberry Pi project to do that not only used external hardware (even if that means only an LED for now), but also reached out into the net to deal with some kind of real time data. I ran into <a href="http://learn.adafruit.com/raspberry-pi-e-mail-notifier-using-leds/overview">this tutorial on adafruit</a> about checking your gmail with a Pi and lighting up an LED based on whether or not you have new mail. This was along the lines of what I wanted to do, but had two drawbacks. One, I don&#8217;t use gmail anymore, and two, it uses a python library called feedparser, which is actually an RSS parser. It only works because apparently you can access your gmail as an RSS feed or something. I wanted to do the same thing, but with any email service that supports, say, IMAP4.</p>
<p>A bit of digging around and I found that Python has an imaplib library that can directly access any IMAP4 based 12mail account. This is included by default in the Python distro that comes with Raspbian. So no further setup there. It took a bit of fiddling around with the docs, both of the library itself and the IMAP4 specs, but I figured out the basic sequence.</p>
<p>The library docs are here: <a href="http://pymotw.com/2/imaplib/">http://pymotw.com/2/imaplib/</a></p>
<p>And the IMAP4 spec is here: <a href="http://tools.ietf.org/html/rfc3501.html">http://tools.ietf.org/html/rfc3501.html</a></p>
<p>First, you create an IMAP object with one of the following lines, depending whether you need SSL or not. My server does need it.</p>
<pre>imap = imaplib.IMAP4(server, port)</pre>
<p>or</p>
<pre>imap = imaplib.IMAP4_SSL(server, port)</pre>
<p>Then, you log in:</p>
<pre>imap.login(user, password)</pre>
<p>You then need to go into select mode to select IMAP folders and messages.</p>
<pre>imap.select()</pre>
<p>Then you can do a search. By default, you&#8217;ll be searching in your inbox, but there are methods to change folders as well. Search criteria are pretty powerful, but I just wanted to see how many unread messages I have. This does that:</p>
<pre>type, data = imap.search(None, "UNSEEN")</pre>
<p>The first parameter is the encoding. Using None will return messages with any encoding. Second param is the search criteria. See the IMAP4 spec linked above for a comprehensive list on what you can search for.</p>
<p>This will return a type, data tuple of strings. The type will be &#8220;OK&#8221; or &#8220;NO&#8221; depending on success of the call. Note, even if it returns no unread messages, you&#8217;ll still get &#8220;OK&#8221; here, with an empty string in the data.</p>
<p>The data will be an list of strings. Actually, it seems to generally be an list containing a single string. This string is a space delimited list of numbers. These numbers are ids of the messages returned by the search. It&#8217;ll be something like this: &#8220;1 2 3 4 5&#8243;.</p>
<p>You can split this into a list of individual ids like so:</p>
<pre>messages = data[0].split()</pre>
<p>And the length of this list tells you how many messages the search returned. Zero means no new mail. One or more and you have new mail! Fire up an LED!</p>
<p>Here&#8217;s the full program I wrote:</p>
<pre>#! /usr/bin/python

import imaplib, time
import RPi.GPIO as GPIO

GREEN_PIN = 25
RED_PIN = 24

class MailChecker:
	def __init__(self, server, port):
		GPIO.setmode(GPIO.BCM)
		GPIO.setup(GREEN_PIN, GPIO.OUT)
		GPIO.setup(RED_PIN, GPIO.OUT)
		GPIO.setwarnings(False)

		try:
			self.m = imaplib.IMAP4_SSL(server, port)
		except:
			self.do_error("Unable to contact server")

	def do_error(self, error):
		# maybe flash another error LED
		print(error)
		exit()


	def log_in(self, user, password):
		try:
			self.m.login(user, password)
		except:
			self.do_error("Unable to log in")

	def check_mail(self):
		type, data = 0, 0
		try:
			self.m.select()
			type, data = self.m.search(None, "UNSEEN")
		except:
			self.do_error("Unable to check messages")

		if type == "NO":
			self.do_error("Problem checking messages")

		self.report(data)

	def start_checking(self, interval):
		while True:
			self.check_mail()
			time.sleep(interval)

	def report(self, data):
		message_count = len(data[0].split())
		if message_count > 0:
			print("You've got %i new messages" %
			message_count)
			GPIO.output(RED_PIN, GPIO.LOW)
			for i in range(1, 100):
        			GPIO.output(GREEN_PIN, GPIO.LOW)
        			time.sleep(.2)
        			GPIO.output(GREEN_PIN, GPIO.HIGH)
        			time.sleep(.2)
		else:
			print("No new mail right now")
			GPIO.output(GREEN_PIN, GPIO.LOW)
			GPIO.output(RED_PIN, GPIO.HIGH)

if __name__ == "__main__":
	user = "your_user_name"
	password = "your_password"
	server = "your_email_server_url"
	port = 993 
	# or whatever port you need to use

	checker = MailChecker(server, port)
	checker.log_in(user, password)
	checker.start_checking(60)</pre>
<p>This creates the IMAP object and logs in. Then the start_checking method sets up an infinite loop that searches once every minute. If it finds there are unread messages, it blinks a green LED a bunch of times then leaves it on. No new mail, red LED. The rest is basic GPIO code.</p>
<p>You can change the behavior however you want, maybe remove all the non-error print lines. Then move it to your Pi, do a chmod +x on it to make it executable and run it as root:</p>
<pre>sudo ./checkmail.py &#038;</pre>
<p>The trailing &#038; character will fork the process and allow you to close the terminal session while keeping the program running &#8211; especially useful if you&#8217;re sshing into your Pi.</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3804</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Ridiculous Raspberry Pi Winamp Remote &#8211; Part II</title>
		<link>http://www.bit-101.com/blog/?p=3799</link>
		<comments>http://www.bit-101.com/blog/?p=3799#comments</comments>
		<pubDate>Wed, 15 May 2013 01:02:04 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3799</guid>
		<description><![CDATA[Send to KindleRecap As stated in my previous post, the plan was to hit a button that&#8217;s connected to my Raspberry Pi, which will trigger Winamp running on my pc laptop to play/pause. This without the Pi being physically connected to the pc &#8211; all via wifi and my local home network. The hardware setup [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p><strong>Recap</strong></p>
<p>As stated in <a href="http://www.bit-101.com/blog/?p=3791">my previous post</a>, the plan was to hit a button that&#8217;s connected to my Raspberry Pi, which will trigger Winamp running on my pc laptop to play/pause. This without the Pi being physically connected to the pc &#8211; all via wifi and my local home network.</p>
<p><strong>The hardware setup</strong></p>
<p>Raspberry Pi with USB wifi, a small breadboard, 100k ohm resistor, a pushbutton and some hookup wire.</p>
<p>GPIO pin 25 goes to one side of the switch, 3.3 volts to the other. You hit the switch, pin 25 gets juice and goes HIGH. The 100k ohm resistor is also hooked to pin 25 on one side and ground on the other, connecting 25 to ground when the switch is not connected, ensuring it is in a LOW state. For those of you in the know, this is a basic pull down resistor. If you&#8217;re not familiar with the concept, as I was not last week, this is a good explanation: <a href="http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/">http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/</a></p>
<p><strong>The Python</strong></p>
<p>The Raspberry Pi is running a simple program written in Python:</p>
<pre>import urllib
import RPi.GPIO as GPIO
import time

BTN = 25
GPIO.setmode(GPIO.BCM)
GPIO.setup(BTN, GPIO.IN)


while True:
        val = GPIO.input(BTN)
        if val == GPIO.HIGH:
                urllib.urlopen("http://192.168.1.14:9000")
                time.sleep(1)</pre>
<p>This just sets up pin 25 as an input and starts an endless loop which reads the value of pin 25. If it&#8217;s high, it pings a url and sleeps for a second. The sleep is so you don&#8217;t get multiple calls at once. There are more robust ways of handling this, but this was quick and dirty and works as long as I&#8217;m the only user and I know not to hold the button down too long.</p>
<p>So what is this url?</p>
<p><strong>The Node</strong></p>
<p>On my laptop where Winamp is playing, I started a simple node server. When a client connects to the server, it calls a function called playPause. This executes an external program called MediaControllerConsole.exe via child_process. </p>
<pre>function playPause() {
	var path = "MediaControllerConsole.exe";

	var exec = require('child_process').exec;
	var child = exec(path, function( error, stdout, stderr) 
	{
	   if ( error != null ) {
	        console.log("err: " + stderr);
	        // error handling &#038; exit
	   }
	});
}

var net = require("net");
var server = net.createServer();
server.on("connection", function(client) {
	playPause();
	client.end();
});

server.listen(9000);</pre>
<p>So what is MediaControllerConsole.exe?</p>
<p><strong>The C#</strong></p>
<p>I had the connection from the Pi to my laptop. Now I needed Node to control Winamp. There may be some way to do this more directly, but I found that I could write a really simple C# console application that called SendKeys.Send() to trigger key presses on the machine. I looked in Winamp&#8217;s options and saw that CTRL-ALT-HOME is a global keyboard shortcut to Winamp&#8217;s pause function. It turns out that this actually acts as a play/pause toggle, which is even more perfect for my use case. Here&#8217;s the C# app I wrote:</p>
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MediaControllerConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Windows.Forms.SendKeys.SendWait("^%{HOME}");
        }
    }
}</pre>
<p>Since this was a console app and not a Windows Forms app, I had to add system.windows.forms.dll as a reference to the Visual Studio project and call SendWait instead of Send (which has more hooks into the forms stuff). The string &#8220;^%{HOME}&#8221; means that while holding the CTRL key (^) and the ALT key (%), press the HOME key.</p>
<p><strong>Final recap</strong></p>
<p>Pressing the button connected to the Pi sends pin 25 to HIGH which triggers Python to call across the wifi network to the Node server which starts a child process running the C# program which sends keystrokes into the system which Winamp is listening for, causing it to play or pause. All so I don&#8217;t have to reach over and press two keys.</p>
<p>Ridiculous! But it works!</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3799</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Ridiculous Raspberry Pi Winamp Remote &#8211; Part I</title>
		<link>http://www.bit-101.com/blog/?p=3791</link>
		<comments>http://www.bit-101.com/blog/?p=3791#comments</comments>
		<pubDate>Wed, 15 May 2013 00:55:29 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[Physical Computing]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3791</guid>
		<description><![CDATA[Send to KindleBack story I wanted a media center. I priced out cases, power supplies, hard drives, cheap motherboards, etc. and figured I could build one for a couple hundred bucks or so. Then I heard about people using Raspberry Pi&#8217;s as media centers. Did a bit of research and got me a Pi and [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p><strong>Back story</strong></p>
<p>I wanted a media center. I priced out cases, power supplies, hard drives, cheap motherboards, etc. and figured I could build one for a couple hundred bucks or so. Then I heard about people using Raspberry Pi&#8217;s as media centers. Did a bit of research and got me a Pi and set up <a href="http://openelec.tv/">OpenElec</a> on it. Plugged in an old 500 GB USB drive. I had a media center for about a quarter of what I was going to pay.</p>
<p>Thing is, getting the Pi set up was so much fun, I decided to buy another one just to play with. A week later I bought an Arduino Uno. I even pulled my barely touched Beagle Board out of cold storage and plugged it in. I&#8217;ve been having a blast the last couple of weeks playing with all these new toys. Bought a bunch of electronic parts, breadboard, hookup wire, gathered up some other junk I had stashed here and there.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130512_001.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/WP_20130512_001-300x168.jpg" alt="Pi, duino, beagle, semi-organized tronics junk" width="300" height="168" class="alignnone size-medium wp-image-3792" /></a></p>
<p><strong>Back back story</strong></p>
<p>When I was 11 or 12 years old, one of my class mates brought in this Radio Shack 75-in-1 Electronics kit and did a little presentation on how to hook up various circuits. I was amazed. I begged and pleaded my mom to get me one for Christmas. I actually remember the exact thought I had at the time &#8211; that with that kit, I would never, ever be bored again. I got my kit, and while the never, ever part was questionable, I certainly spent many, many, many hours playing with electronics over the next few years. I outgrew the kit and bought all sorts of other build-it-yourself stuff. I learned how to solder. I could tell you the difference between pnp and npn transistors and precisely how they worked on a molecular level.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/05/75in1.jpg"><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/05/75in1-300x254.jpg" alt="75in1" width="300" height="254" class="alignnone size-medium wp-image-3793" /></a></p>
<p>Where I grew up was a vocational school, Blue Hills Regional, that offered an electronics program. It was perfect timing. I signed up to go there for high school. Then disaster struck, in the form of my own bad judgment. My stepfather was an electrician. In some misguided attempt to win favor with him, I switched from the electronics program to the electrical program and wound up becoming an electrician myself. I learned soon after graduation how much I hated being an electrician, stopped doing it, and it wasn&#8217;t until about 15 years later that I discovered Flash and programming and a similar joy to what I had found doing electronics.</p>
<p><strong>Back to the present</strong></p>
<p>So getting involved with the Raspberry Pi and Arduino and Beagle Board, I found myself playing with LEDs and resistors for the first time in decades. It&#8217;s been great rediscovering all this stuff I used to know back when I was just a kid. So I&#8217;ve become a master at making LEDs blink, but I wanted to do something that could be considered practical on some small level.</p>
<p><strong>The problem</strong></p>
<p>Great projects are often the result of solving some problem. My problem is controlling the media on my pc. These days I&#8217;m doing work on my Mac, but usually have some podcast or music playing on Winamp on my pc laptop. If I want to pause or restart, I either have to move the mouse over there (I&#8217;m using Synergy) and click on the play button. Or reach over and hit the function key and the media play/pause key. It&#8217;s a horrible problem, I know. Not sure how I&#8217;ve managed to go on this long. I try to be strong.</p>
<p>But my thought was to have a single button sitting on the desk. I push the button, the media toggles. A bizarre plan started to form. Have a button hooked to the Pi send a message across the network to toggle the music state. I have achieved this. And I&#8217;m sitting in the living room clicking this button relentlessly, starting and stopping the music playing in my home office. My wife has just retreated upstairs, pretending not to be annoyed.</p>
<p><strong>The solution</strong></p>
<p>Crap, this post is already too damn long. Stay tuned for Part II in which our hero details how he accomplished this nearly impossible feat in the most convoluted way possible, using only Python, Node.js and C#.</p>
<p>Click for  <a href="http://www.bit-101.com/blog/?p=3799">Part II</a> of this amazing saga.</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3791</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joining the Magic Kingdom</title>
		<link>http://www.bit-101.com/blog/?p=3783</link>
		<comments>http://www.bit-101.com/blog/?p=3783#comments</comments>
		<pubDate>Wed, 03 Apr 2013 01:00:33 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3783</guid>
		<description><![CDATA[Send to KindleI purposely held off until today to break this news as I didn&#8217;t think anyone would believe it if I posted it on April 1. After 5 1/2 years with Infrared5, I am moving on to new endeavors. Specifically, I&#8217;ve signed on with Playdom, which is part of Disney Interactive. The position is [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p>I purposely held off until today to break this news as I didn&#8217;t think anyone would believe it if I posted it on April 1.</p>
<p>After 5 1/2 years with <a href="http://www.infrared5.com">Infrared5</a>, I am moving on to new endeavors. Specifically, I&#8217;ve signed on with <a href="http://www.playdom.com">Playdom</a>, which is part of Disney Interactive. The position is a principal engineer / senior architect type of role. I&#8217;m still getting my head around the structure, but basically Playdom oversees a dozenish semi-independent game studios. I&#8217;ll be in the core technology unit, architecting, coordinating, building libraries, etc. I&#8217;m excited to get started next week. The offices are in Palo Alto, but I&#8217;ll continue to live in the Boston area, work remotely from home, and fly out west every once in a while.</p>
<p>I leave Infrared5 on good terms. Everyone there is great. Several were good friends before they were coworkers, and I&#8217;m sure those friendships will continue. There are actually a lot of exciting changes going on there and I wish everyone there all the best. But professionally, although it was a very tough decision to leave, it was time to move on and try something new. As I wrapped up my last project yesterday, I made that my last day and am enjoying the rest of the week as a mini-vacation before starting up the new gig next Monday.</p>
<p>As for how I wound up at Playdom, it all started back in 2004 when I met this guy named <a href="https://twitter.com/jagosan">Jago McLeod</a> at Flash Forward in San Francisco. A year or so later he contacted me about working for this company called Flash Composer out in Santa Cruz, which I wound up doing. Although management of the company was not the best and it went under a couple of years later, I really enjoyed working with Jago. He&#8217;s brilliant, funny, very organized, and just all around a great guy. We&#8217;ve stayed in touch off and on since then, and recently we bumped into each other on line. He told me he had become the VP of Engineering at Playdom and once again offered me a job on the other side of the country. And once again, I accepted.</p>
<p>So there you have it. I&#8217;m sure there will be more to talk about in a few weeks once I&#8217;ve settled in.</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3783</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Send to Kindle</title>
		<link>http://www.bit-101.com/blog/?p=3779</link>
		<comments>http://www.bit-101.com/blog/?p=3779#comments</comments>
		<pubDate>Wed, 20 Mar 2013 18:05:09 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[Kindle]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3779</guid>
		<description><![CDATA[Send to KindleJust a quick note that I added the &#8220;Send to Kindle&#8221; plugin to the site here. At the bottom of each post you should see a Send to Kindle button that will prompt you to log in to your Amazon account and send that post to  any registered Kindle. I know it&#8217;s something [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p>Just a quick note that I added the &#8220;Send to Kindle&#8221; plugin to the site here. At the bottom of each post you should see a Send to Kindle button that will prompt you to log in to your Amazon account and send that post to  any registered Kindle. I know it&#8217;s something I do a lot with posts I&#8217;m reading on other sites via the Chrome extension. So it&#8217;s nice that Amazon has created this.</p>
<p><ins datetime="2013-03-20T19:34:24+00:00">Just pointed out to me that the button might be better on the top of the post. I originally put it at the bottom, because that&#8217;s where the other &#8220;share&#8221; type buttons go. But it&#8217;s a good point because you see those buttons when you are done reading, but you might want to see this one before you read. So I put it in both places! Looks silly on a short post like this, but fine on a larger one.</ins></p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3779</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a MAME Arcade</title>
		<link>http://www.bit-101.com/blog/?p=3743</link>
		<comments>http://www.bit-101.com/blog/?p=3743#comments</comments>
		<pubDate>Sat, 09 Mar 2013 02:19:08 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3743</guid>
		<description><![CDATA[Send to KindleBackground I grew up in the 70&#8242;s and 80&#8242;s. The golden age of arcade games. My best friend and I would hit up the various arcades in the surrounding town, and at 25 cents a game, I&#8217;d easily spend $10 for a couple hours of entertainment. My favorite game of all time, hands-down, [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p><strong>Background</strong></p>
<p>I grew up in the 70&#8242;s and 80&#8242;s. The golden age of arcade games. My best friend and I would hit up the various arcades in the surrounding town, and at 25 cents a game, I&#8217;d easily spend $10 for a couple hours of entertainment. My favorite game of all time, hands-down, is Tempest. In the arcades of the South Shore of Boston, I was the second best player. I could walk in to any arcade and get my initials on the high score board. Most often, after a few games I could get to the number one spot. Unless my nemesis had been there before me. Who this other person was, I have no idea. He (possibly she, but given the demographics of the time, most likely he) wasn&#8217;t amazingly better than me, but better enough to nudge me out of the top spot. I could usually get a number two spot though.</p>
<p>I was the guy people would stand behind and stare at in amazement. Granted, the only time I got such attention at that age was while playing video games, and only that particular one. I was pretty good at plenty of others, but Tempest was my forte.</p>
<p><strong>Later years: Enter MAME</strong></p>
<p>Well, time marched on, I grew up, arcades were replaced by home computers and XBoxes, etc. But I always remembered those old time games. Of course, I&#8217;ve installed MAME a dozen times and sought out various ROMs and had a good old time with them, but the holy grail of reliving Tempest was always out of reach. The problem was that Tempest requires a spinner. You spin the spinner to move around the screen and shoot the stuff that&#8217;s coming out of the tubes at you. There are plenty of workable Tempest ROMs for MAME, and Flash versions, and various copies. But moving around with the keyboard or mouse was an utterly lame experience compared to the real thing. A few years ago I went as far as getting a Griffin Powermate, thinking that&#8217;d work. No such luck. First of all, I was unable to even get it to talk to MAME successfully, and what I heard from those who had, was that it didn&#8217;t work all that well anyway.</p>
<p><strong>Let&#8217;s just DO this</strong></p>
<p>I most recently installed MAME while working on <a href="http://apps.microsoft.com/windows/app/infiltration/c49cce6a-f04f-4fc8-81e9-a908d9143585">my Infiltration game</a>, in order to get some Gravitar inspiration (another favorite). Of course, I gave Tempest another shot and had another bout of frustration. But this time I took it one step further and started to look into real game controls. Starting with these sites:</p>
<p><a href="http://wiki.arcadecontrols.com/wiki/Main_Page">http://buildahomearcade.com/</a></p>
<p><a href="http://wiki.arcadecontrols.com/wiki/Main_Page">http://wiki.arcadecontrols.com/wiki/Main_Page</a></p>
<p>I came up with a list of vendors that sold game controls and various plans on how to put them together. I got a shopping list together from <a href="http://www.ultimarc.com/">Ultimarc</a> and bought some wood and started cutting and drilling. My plan was to first create an arcade control panel that I could just plug into any computer running MAME. Some people go all out with two- or even four-player control panels. I decided to start with a single player. I ordered a bunch of buttons, a joystick, a control interface, and the ultimate &#8211; a real arcade spinner.</p>
<p><strong>The work</strong></p>
<p>&nbsp;</p>
<p>While I waited for the controls to arrive, I started preparing the wood. I bought a 2&#8242;x4&#8242; sheet of half-inch wood at the local Home Depot. I cut a 1&#8242; strip off the end to give me the 1&#8242;x2&#8242; top of the control panel.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130302_002.jpg"><img class="alignnone size-medium wp-image-3745" alt="WP_20130302_002" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130302_002-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Ye olde workshop. (Yes, I keep a bottle of wine in my workshop. Don&#8217;t you?)</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130302_003.jpg"><img class="alignnone size-medium wp-image-3746" alt="WP_20130302_003" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130302_003-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Control top.</p>
<p>Then I cut a piece of cardboard to the same size and experimented with some layouts, coming up with one I liked.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130302_004.jpg"><img class="alignnone size-medium wp-image-3747" alt="WP_20130302_004" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130302_004-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>The plan was to have the joystick and spinner in the center, and three buttons on each side. Some games are all button based, like Gravitar or Asteroids &#8211; a pair of buttons turn you left and right and other buttons shoot, thrust, shield, etc. These are usually laid out with buttons on opposite sides of the panel. Other games are joystick / button based, and of course Tempest is spinner / button based. Generally, the joystick or spinner is to the right and controlled with the right hand and the shooting / jumping / action buttons are hit with the left hand. Thus, the main buttons are the ones on the left here. Then, on the top are the coin button and start game button (one player start).</p>
<p>That was about as far as I got before the controls arrived.</p>
<p><strong>The controls are here!!!</strong></p>
<p>The controls arrived on Wednesday of last week. Pretty quick considering I ordered on Satureday and they originated in London. I actually did not realize that when I placed the order with Ultimarc. But I&#8217;m VERY happy with what they provided, as well as the prompt service and quick shipping. Here&#8217;s everything:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_001.jpg"><img class="alignnone size-medium wp-image-3748" alt="WP_20130306_001" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_001-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Doesn&#8217;t seem like a whole lot for $200 something. But I have zero regrets.</p>
<p>What you see here are:</p>
<p>A. 7 <a href="http://www.ultimarc.com/goldleaf.html">gold leaf buttons</a>. Actually I ordered 6, they threw in an extra green one.</p>
<p>B. A <a href="http://www.ultimarc.com/controls.html">J-Stik joystick</a> with red ball top.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_003-e1362792369733.jpg"><img class="alignnone size-medium wp-image-3750" alt="WP_20130306_003" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_003-e1362792369733-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>C. A <a href="http://www.ultimarc.com/SpinTrak.html">SpinTrak spinner</a>. With a silver/red spin top and extra heavy flyweight. The weight gives it momentum. This thing will spin for a minute or more.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_004-e1362792562197.jpg"><img class="alignnone size-medium wp-image-3751" alt="WP_20130306_004" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_004-e1362792562197-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>D. A <a href="http://www.ultimarc.com/minipac.html">MiniPac interface</a>. With full wiring harness.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_002-e1362792883593.jpg"><img class="alignnone size-medium wp-image-3749" alt="WP_20130306_002" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_002-e1362792883593-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>This lets you hook up a joystick, all your buttons, a spinner, as well as a trackball. You then hook it up to your computer via a mini USB cable and you&#8217;re good to go. It basically converts all the buttons and joystick movements into key presses, and spinner and trackball input into mouse signals. It&#8217;s set up out of the box to work with standard MAME inputs, but it&#8217;s also programmable so you could make any control send whatever signal you want. Here&#8217;s how you wire it up:</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/minipac_wiring.jpg"><img class="alignnone size-medium wp-image-3771" alt="minipac_wiring" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/minipac_wiring-300x197.jpg" width="300" height="197" /></a></p>
<p>&nbsp;</p>
<p>Took me two or three tries to figure it all out, but once you get the logic, it&#8217;s fairly simple. I could rewire the whole thing in five minutes at this point. The wiring harness is well worth it too &#8211; you just look up the color and hook it to whatever control it&#8217;s supposed to go to.</p>
<p><strong>Alpha Test</strong></p>
<p>My control panel wasn&#8217;t ready yet &#8211; no holes drilled or anything, but you know I had to see this thing in action. So I put my laptop down on the living room floor and started hooking up wires. Again, there were a few false starts, but I eventually got it at least partway functional.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_006.jpg"><img class="alignnone size-medium wp-image-3752" alt="WP_20130306_006" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_006-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Dang, that&#8217;s a mess o&#8217; wires!</p>
<p>I grabbed one of the cardboard boxes that the stuff came in and cut a couple of 1 1/8&#8243; holes in it. Stuck the #1 button in one and the spinner in the other. And fired up&#8230; Tempest! I wish I could describe how awesome that was and how excited I was, but you&#8217;d probably get really uncomfortable and click off to some other site. Anyway, playing Tempest with a real spinner, even if only mounted in a cardboard box was nerd nirvana. Several hundred times better than trying to make it work with a keyboard or mouse.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_007.jpg"><img class="alignnone size-medium wp-image-3753" alt="WP_20130306_007" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_007-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Here&#8217;s my daughter Kris getting her first taste of Tempest. She likes.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_008.jpg"><img class="alignnone size-medium wp-image-3754" alt="WP_20130306_008" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_008-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>High tech.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_009.jpg"><img class="alignnone size-medium wp-image-3755" alt="WP_20130306_009" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_009-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Now you&#8217;ve seen my slippers. Feel like you know me better?</p>
<p>As for the joystick, I got that wired backwards AND upside down the first time. After switching all the wires I realized I just could have flipped the thing 180 degrees. I didn&#8217;t mount that in anything, just held it steady while Kris got her first experience with Space Invaders.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_011.jpg"><img class="alignnone size-medium wp-image-3756" alt="WP_20130306_011" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130306_011-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>That&#8217;s the look of pure retro joy. Take THAT, Wii!</p>
<p><strong>Making sawdust</strong></p>
<p>Thursday night&#8217;s project was to mount this thing in the real control panel. Based on my cardboard plan, I marked out where I wanted all the holes to be.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_001.jpg"><img class="alignnone size-medium wp-image-3757" alt="WP_20130307_001" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_001-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Then drilled some starter holes.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_002.jpg"><img class="alignnone size-medium wp-image-3758" alt="WP_20130307_002" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_002-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Then used a 1 1/8&#8243; spade bit to cut out the final holes.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_005.jpg"><img class="alignnone size-medium wp-image-3760" alt="WP_20130307_005" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_005-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Conveniently, the buttons and the spinner both fit in the same size hole, and that works well for the joystick as well.</p>
<p>Started mounting the components.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_006.jpg"><img class="alignnone size-medium wp-image-3761" alt="WP_20130307_006" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_006-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>And wiring things up in back.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_007.jpg"><img class="alignnone size-medium wp-image-3762" alt="WP_20130307_007" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_007-300x168.jpg" width="300" height="168" /></a></p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_008.jpg"><img class="alignnone size-medium wp-image-3763" alt="WP_20130307_008" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_008-300x168.jpg" width="300" height="168" /></a></p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_009.jpg"><img class="alignnone size-medium wp-image-3764" alt="WP_20130307_009" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_009-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Here&#8217;s the frame for the sides.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_004.jpg"><img class="alignnone size-medium wp-image-3759" alt="WP_20130307_004" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130307_004-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Right now, the top sites loosely on top of the frame, but I glued some blocks to it so it doesn&#8217;t slide around.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_001-e1362794215975.jpg"><img class="alignnone size-medium wp-image-3765" alt="WP_20130308_001" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_001-e1362794215975-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Then put the bottom onto the frame and drilled a hole for the USB cable.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_006.jpg"><img class="alignnone size-medium wp-image-3770" alt="WP_20130308_006" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_006-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>A bit of cable management.</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_002.jpg"><img class="alignnone size-medium wp-image-3766" alt="WP_20130308_002" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_002-300x168.jpg" width="300" height="168" /></a></p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_003.jpg"><img class="alignnone size-medium wp-image-3767" alt="WP_20130308_003" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_003-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>And we are good to go!</p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_004.jpg"><img class="alignnone size-medium wp-image-3768" alt="WP_20130308_004" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_004-300x168.jpg" width="300" height="168" /></a></p>
<p><a href="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_005.jpg"><img class="alignnone size-medium wp-image-3769" alt="WP_20130308_005" src="http://www.bit-101.com/blog/wp-content/uploads/2013/03/WP_20130308_005-300x168.jpg" width="300" height="168" /></a></p>
<p>&nbsp;</p>
<p>Yeah, there&#8217;s one button missing, but few games actually use all 6 anyway. Originally I ordered 6 buttons thinking of just the 6 player buttons. I can still control MAME, enter coins and start using the keyboard. But when the extra button came, I decided to skip button six for now and implement the coin and player one start buttons on the top. I&#8217;m ordering some more buttons anyway &#8211; I&#8217;ll probably add a pause, reset and select at least.</p>
<p>The cabinet itself is completely unfinished at this point. But we&#8217;re having a blast with it. It&#8217;s amazing seeing my wife get into it as much as she is. She grew up in the same time and who knew she knows various Space Invaders strategies. She even mentioned some by name. Daaaaamn! The woman is geekier than she lets on. And it&#8217;s really awesome to see Kris discovering and enjoying the games that I grew up with. Anyway, I&#8217;ll eventually get around to sanding it down a bit and will probably just stain and shellac it. I&#8217;m already looking into project number two, which will be a standalone mini table top arcade cabinet, <a href="http://wiki.arcadecontrols.com/wiki/Bartop/Countertop">something like one of these</a>. And if that goes well, I might even attempt a full size two-player model.</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3743</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8220;Infiltration&#8221; live in Windows Store</title>
		<link>http://www.bit-101.com/blog/?p=3727</link>
		<comments>http://www.bit-101.com/blog/?p=3727#comments</comments>
		<pubDate>Tue, 26 Feb 2013 00:57:57 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[Windows 8]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3727</guid>
		<description><![CDATA[Send to KindleMy latest game, Infiltration, for Windows 8 is live in the Windows Store. Get it here! This is a game that I&#8217;ve wanted to make for a long time. One of my favorite old time arcade games was Gravitar. I&#8217;ve played it a bunch in the last year or so on MAME. It&#8217;s [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p>My latest game, Infiltration, for Windows 8 is live in the Windows Store.</p>
<p><a href="http://apps.microsoft.com/windows/en-US/app/infiltration/c49cce6a-f04f-4fc8-81e9-a908d9143585">Get it here!</p>
<p></a></p>
<p><img class="alignnone  wp-image-3728" alt="screenshot_02242013_131048" src="http://www.bit-101.com/blog/wp-content/uploads/2013/02/screenshot_02242013_131048-1024x575.png" width="614" height="345" /></p>
<p>This is a game that I&#8217;ve wanted to make for a long time. One of my favorite old time arcade games was Gravitar. I&#8217;ve played it a bunch in the last year or so on MAME. It&#8217;s such a difficult game, but very addicting for me anyway. Infiltration is a homage to that game. It has a lot of the same basic game play &#8211; you fly a ship into an area, avoid getting shot or running out of fuel while achieving an objective. In Gravitar the only real objective is to destroy all the guns. In Infiltration there is a target or multiple targets you need to capture. When all targets are captured, the exit appears and you use it to complete the level. Destroying all the guns and collecting all the fuel is optional, but worth bonus points.</p>
<p>The game has 30 levels in the full version, which sells for $1.49 US. There&#8217;s also a trial version which gives you a sampling of several levels. In keeping with the spirit of Gravitar, some of these levels are very hard. The full version also supports loading of custom levels which can be created with the free Infiltration Level Editor, another app which has been submitted to the Windows Store just today and which should hopefully be available soon.</p>
<p>I wrote Infiltration (and the level editor) in HTML and JavaScript, with a mix of canvas and DOM elements. The Visual Studio JavaScript profiler was crucial in optimizing the game to run smoothly at 60 fps with quite a bit of collision detection and animation going on. It was a blast to use, digging into bottlenecks, fixing them up and seeing a marked improvement.</p>
<p>I originally wrote the level editor just for myself to facilitate creating of the official levels for the game. But I had so much fun making it and spent so much time polishing it that it wound up being a full featured app that I had no reservations about releasing.</p>
<p><img class="alignnone  wp-image-3737" alt="screenshot_02252013_182513" src="http://www.bit-101.com/blog/wp-content/uploads/2013/02/screenshot_02252013_182513-1024x575.png" width="614" height="345" /></p>
<p>As for the submission process of the game itself, this was the smoothest and fastest process I&#8217;ve ever encountered for an app submission process. I wrapped things up Sunday night and submitted it to the store. Monday morning when I woke up, there was a rejection notice. This had to do with submissions to foreign stores, namely Korea, Brazil, Taiwan, and South Africa. These countries currently require actual certification of game ratings. I&#8217;ll be looking into getting such certification for this and future games, but I wasn&#8217;t going to hold things up so I had to take those off the list for now. Anyway, I unchecked those countries, resubmitted, and a few hours later the app was approved and live in the store! I don&#8217;t know what the iOS App Store process is like now, but back when I was doing apps there such a situation would have meant a week and a half setback. This time I had submission, rejection, fix, resubmission, and approval &#8211; all within 18 hours! I&#8217;m hoping the level editor goes as quickly.</p>
<p>My previous app and game were free. This is my first attempt at the try/buy scenario. I&#8217;m not expecting to get rich, but looking forward to seeing what can be done in this environment. I&#8217;ll report how it goes.</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3727</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Surface Pro</title>
		<link>http://www.bit-101.com/blog/?p=3718</link>
		<comments>http://www.bit-101.com/blog/?p=3718#comments</comments>
		<pubDate>Sun, 10 Feb 2013 12:58:24 +0000</pubDate>
		<dc:creator>keith</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Windows 8]]></category>

		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=3718</guid>
		<description><![CDATA[Send to KindleBackground A few years back I was invited to Microsoft for a day with a small group of other bloggers to be briefed on what MS had going on and to speak with Bill Gates himself for a full hour. One of the things they showed us was the early prototype of the [...]]]></description>
				<content:encoded><![CDATA[<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div><p><strong>Background</strong></p>
<p>A few years back I was invited to Microsoft for a day with a small group of other bloggers to be briefed on what MS had going on and to speak with Bill Gates himself for a full hour. One of the things they showed us was the early prototype of the Microsoft Surface. At the time, it was basically a touch screen table. And it was amazing. This was before anyone had seen an iPhone or an iPad, so seeing and touching a real time interactive multitouch device left us all in awe. They also said that the future of the Surface probably included a more portable device &#8211; something you could carry from room to room, and maybe hang on the wall to watch movies,s play games, etc.</p>
<p>Well, time went by, people started creating other touch screen devices, the iPad came out and blew everyone away and the Surface became a rumored, yeti-like creature.</p>
<p>Then, some time last year, this video was released:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/dpzu3HM2CIo" frameborder="0" allowfullscreen></iframe></p>
<p>This video definitely captured my attention. And as more and more info on the Surface came out, I kept getting more interested. My weapon of choice has been a Lenovo T520 laptop. I love it to death, but it&#8217;s rather large. I&#8217;ve been eyeing various ultra-book type devices for a while now, but nothing out there really did it for me. And that upcoming Surface was still in the back of my mind.</p>
<p>Last fall, the Surface RT was released. This, unfortunately, did not interest me at all. RT only runs RT apps. It wouldn&#8217;t work for what I wanted it for. I wanted something I could use to do actual work, a full featured pc. So I&#8217;ve been holding out to see what the Surface Pro looked like.</p>
<p>So last week I ventured into the Microsoft Store at the Prudential Center Mall in Boston and checked out the prerelease demo models. I liked it. You couldn&#8217;t buy them or preorder them, but they would let you reserve one. I didn&#8217;t really expect they&#8217;d sell out early on release day (Saturday, February 9), but I figured it couldn&#8217;t hurt to put in a reservation.</p>
<p>Well, the day before release, New England had a massive blizzard, which shut down the area. In fact, a state of emergency was declared, the subway system was shut down and a travel ban on public roads was enacted. So it didn&#8217;t look like I&#8217;d be picking up my Surface on Saturday.</p>
<p>By late Saturday morning, the on-line store had sold out of Surface Pro 128 GB models, and there were reports of stores with long &#8220;Apple-like&#8221; lines selling out of the devices as well. I honestly didn&#8217;t expect that. So in the afternoon, when it became nice and sunny out and I had the car all dug out, I actually considered going in. I called the store to ensure they were open. I found out later that Microsoft had put all the employees up at a local hotel so they could get into the store in the morning for launch day. They were open, but informed me before I even asked that they had no more Surface Pros left. I said I had a reservation card and after a few minutes on hold, they said if I could make it in, they&#8217;d take care of me.</p>
<p>I made it in and got a 128 GB Surface Pro with a touch cover. All went smoothly. The best thing that happened in the store though, was overhearing this conversation between a woman who walked into the store and an employee:</p>
<p>Woman: &#8220;Do you have any iPhones in stock?&#8221;<br />
MS Guy: &#8220;&#8230; um, no, this is the Microsoft Store. If you want an iPhone, you need to go to the Apple Store.&#8221;<br />
Woman: &#8220;Oh&#8230; hmm&#8230; OK. &#8230; So you don&#8217;t have ANY???&#8221;</p>
<p><strong>First Impressions</strong></p>
<p>Thanks for putting up with all that, when what you really want to know is how the device itself is.</p>
<p>Short story: I like it a lot. Not sure if I love it yet or not. Much like Windows 8 itself, it&#8217;s so different than anything else that I think it&#8217;s going to take a while to figure out how it fits into my technological life.</p>
<p>The Surface is kind of like a tablet, but a bit heavy to walk around with and use one-handed like an iPad. It also doesn&#8217;t have the extended battery life that your usual tablet does. Average reports of around 5 hours. </p>
<p>But that extra weight brings you a lot. This is a very full featured computer with a core i5 processor running full Windows 8. I can install any program on here that I can install on a regular laptop or desktop Windows pc. And it runs those programs well.</p>
<p>The type cover is great. It snaps in solidly with a very strong magnet and is extremely usable. The screen is beautiful. It&#8217;s a bit small. I&#8217;m not sure how well I can use the screen itself for an everyday work pc. But it will connect to an external display.</p>
<p>The keyboard also has a track pad which, while not the best track pad I&#8217;ve ever used, is far from the worst. I actually find myself using it fairly often. When in desktop apps, the UI elements can be fairly small and hard to hit with a fat finger, so the track pad comes in handy.</p>
<p>The surface also come with a pen. This uses licensed Wacom technology, so the experience of using the pen as a drawing tool is outstanding. To be honest, the pen feels a bit cheap and plasticy compared to the beautifully solid build quality of the device itself. But it works, and is another option I sometimes use for hitting small ui elements in desktop apps.</p>
<p>Overall, the experience of using the device is very good. It&#8217;s small enough that when you are typing, your fingers are close enough to the screen that it&#8217;s quite natural to use the touch screen as needed.</p>
<p>There was a big media frenzy in the last couple of weeks about the  available storage on the Surface devices being &#8220;less than advertised&#8221;. A real bunch of FUD, in my opinion. Yes, the OS and essential programs are going to take up space. Windows 8 is a full operating system, not a mobile OS, so it&#8217;s rather large. But <a href="http://www.wpcentral.com/does-size-really-matter-surface-pro-provides-more-room-macbook-air">this post really made my day</a>, showing that a 128 GB Surface has just barely less usable storage than a 128 GB Mac Book Air. In fact, if you move the recovery partition off, it has more.</p>
<p><img src="http://www.bit-101.com/blog/wp-content/uploads/2013/02/surfacemacbookzdnetcompare.png" alt="surfacemacbookzdnetcompare" width="620" height="357" class="alignnone size-full wp-image-3720" /></p>
<p>Anyway, like I said, still getting used to this device and feeling out where it fits and what I&#8217;m going to use it for. I&#8217;ll report more as that becomes more clear.</p>
<div class='kindleWidget kindleLight' ><img src="http://www.bit-101.com/blog/wp-content/plugins/send-to-kindle/media/white-15.png" /><span>Send to Kindle</span></div>]]></content:encoded>
			<wfw:commentRss>http://www.bit-101.com/blog/?feed=rss2&#038;p=3718</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
