<?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>dandr.org &#187; Arduino</title>
	<atom:link href="http://dandr.org/category/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://dandr.org</link>
	<description></description>
	<lastBuildDate>Thu, 29 Apr 2010 15:13:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Arduino + Scalextric = lap counter</title>
		<link>http://dandr.org/2010/02/arduino-scalextric-lap-counter/</link>
		<comments>http://dandr.org/2010/02/arduino-scalextric-lap-counter/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 21:52:16 +0000</pubDate>
		<dc:creator>Dave Nice</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://dandr.org/?p=11</guid>
		<description><![CDATA[I bought an Arduino board last year and have been playing around with it on and off since.  I&#8217;ve had a few ideas for projects but not really got around to completing anything except monitoring my gas meter. For a few months I&#8217;ve been hankering after a scalextric (even before James May&#8217;s excellent Toy Stories [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Arduino lap counter" src="http://farm5.static.flickr.com/4070/4326390906_344fe24fb0_m.jpg" alt="" /></p>
<p>I bought an Arduino board last year and have been playing around with it on and off since.  I&#8217;ve had a few ideas for projects but not really got around to completing anything except monitoring my gas meter.</p>
<p>For a few months I&#8217;ve been hankering after a scalextric (even before James May&#8217;s excellent Toy Stories programme about it) so when a friend invited me round to have a go on his, I jumped at the chance!</p>
<p>I took along my arduino, he dug out a pair of cycle computer sensors and we had a go at hacking together a lap counter. <span id="more-11"></span> We sellotaped the cycle computer sensors (reed switches) under the track, wired it up, and I wrote a bit of arduino code to poll for a change in voltage and increment the lap count.</p>
<p>The code worked in testing, but once we actually drove the cars round a lot of the laps weren&#8217;t registered.  I think the problem was that the magnet in the bottom of the car is quite small and isn&#8217;t close to the reed switch for long as the car drives over.  My poll frequency was not high enough to keep up.  The obvious solution was to increase the polling frequency but I&#8217;m not massively keen on polling and was keen to investigate arduino interrupts.</p>
<p>The standard arduino has two interrupts that are immediately available (see the <a title="arduino documentation" href="http://www.arduino.cc/en/Reference/AttachInterrupt" target="_self">arduino documentation</a>).  The arduino comes with <a href="http://en.wikipedia.org/wiki/Pull-up_resistor">pullup resistors</a> built-in for the digital inputs, so I connected the reed switches between the input pins and the ground pin.  Because the reed switch connects the input to ground, I used the FALLING mode of the interrupt.  Again, the arduino documentation explains how to enable the <a href="http://www.arduino.cc/en/Tutorial/DigitalPins">pullup resistors</a>.<br />
<img class="alignleft" title="Lap counter display" src="http://farm5.static.flickr.com/4019/4326390152_41e31142ce_m.jpg" alt="" /><br />
At this point a function in the arduino code gets called each time a car drives over the sensor &#8211; it&#8217;s just a case of writing some code to track the number of laps and the times of each lap. I&#8217;ve used <a href="http://blog.thiseldo.co.uk/?p=383">Andy&#8217;s arduino Nokia LCD library</a> to handle drawing to the screen.</p>
<p>The main problem I&#8217;ve had with this project is the reed switches.  First first switch I tried didn&#8217;t work correctly, the second switch didn&#8217;t seem sensitive enough to trigger reliably &#8211; I couldn&#8217;t put the switches directly under the centre of the car (I think the metal rails interfered), and having them slightly off centre seemed hit and miss.  I&#8217;ve upgraded to some slightly bigger switches which seems to have made things a lot more reliable.  Of course, if your scalextric car doesn&#8217;t have magnatraction, it won&#8217;t work!</p>
<p>The counter doesn&#8217;t look as good as the <a href="http://techcobweb.wordpress.com/2009/09/02/slot-car-challenge/">SlotCarDuino project</a>, I&#8217;m not quite as creative on the hardware side, but hasn&#8217;t been too hard to put together and hasn&#8217;t involved cutting my track up at all <img src='http://dandr.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>In terms of ideas for the future, I quite like the idea of publishing laps across the network using my network shield and providing a richer web-based interface.  I plan to add in sound to indicate that a lap has registered and whether it&#8217;s a best lap.﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://dandr.org/2010/02/arduino-scalextric-lap-counter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

