<?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>work in progress</title>
	<atom:link href="http://www.workinprogress.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.workinprogress.ca</link>
	<description>of patrick sébastien</description>
	<lastBuildDate>Mon, 13 May 2013 00:56:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>theremin à crayon</title>
		<link>http://www.workinprogress.ca/theremin-a-crayon/</link>
		<comments>http://www.workinprogress.ca/theremin-a-crayon/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 18:50:28 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Pure Data]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=1748</guid>
		<description><![CDATA[The &#8220;Not-just-for-sci-fi electronic instrument&#8221; that is played without being touched + a graphic tablet on top &#038; some very simple electronics in the case (power / convert the theremin via USB). Both antennas (control voltage for volume and pitch) are routed to PureData. The patch is really just a bridge (open sound control) to MyPaint [...]]]></description>
				<content:encoded><![CDATA[
<a href='http://www.workinprogress.ca/theremin-a-crayon/img_0228/' title='IMG_0228'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/IMG_0228-150x150.jpg" class="attachment-thumbnail" alt="IMG_0228" /></a>
<a href='http://www.workinprogress.ca/theremin-a-crayon/img_0237/' title='IMG_0237'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/IMG_0237-150x150.jpg" class="attachment-thumbnail" alt="IMG_0237" /></a>
<a href='http://www.workinprogress.ca/theremin-a-crayon/tac_tv/' title='tac_tv'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/tac_tv-150x150.jpg" class="attachment-thumbnail" alt="tac_tv" /></a>
<a href='http://www.workinprogress.ca/theremin-a-crayon/img_0226/' title='IMG_0226'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/IMG_0226-150x150.jpg" class="attachment-thumbnail" alt="IMG_0226" /></a>
<a href='http://www.workinprogress.ca/theremin-a-crayon/theremin/' title='theremin'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/theremin-150x150.png" class="attachment-thumbnail" alt="theremin" /></a>

<div style="margin-top: 20px;"></div>
<p>The &#8220;Not-just-for-sci-fi electronic instrument&#8221; that is played without being touched + a graphic tablet on top &#038; some very simple electronics in the case (power / convert the theremin via USB). Both antennas (control voltage for volume and pitch) are routed to <strong><a href="http://www.puredata.info">PureData</a></strong>.</p>
<p>The patch is really just a bridge (open sound control) to <strong><a href="http://mypaint.intilinux.com">MyPaint</a></strong> (open-source graphics application for digital painters). Right now the volume is linked to the diameter of the brush and the pitch is linked to the brightness color (this can be changed in the code see below).</p>
<p>BTW this is the beauty of the open source movement: had the idea in the morning, talk to some people on #mypaint in the afternoon, hack the source for my needs during the night and went to bed with a working prototype. <strong>Ready-made Solutions Require Ready-made Problems; For Everything Else There Is Open Source Software!</strong></p>
<h3>Video</h3>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/LsOV1Gfhk4Q?rel=0&#038;wmode=transparent" frameborder="0" allowfullscreen></iframe></p>
<h3>Source</h3>
<p>MyPaint: share/gui/document.py -> pyliblo server (receive from pd)</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> liblo<span style="color: #66cc66;">,</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> Document <span style="color: black;">&#40;</span>CanvasController<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> app<span style="color: #66cc66;">,</span> leader<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
		<span style="color: #ff7700;font-weight:bold;">global</span> created
		<span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span>created <span style="color: #66cc66;">==</span> <span style="color: #008000;">False</span><span style="color: black;">&#41;</span>:
			<span style="color: #008000;">self</span>.<span style="color: black;">server</span> <span style="color: #66cc66;">=</span> liblo.<span style="color: black;">Server</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">9997</span><span style="color: black;">&#41;</span>
			<span style="color: #008000;">self</span>.<span style="color: black;">server</span>.<span style="color: black;">add_method</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/mp/radius&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'f'</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">self</span>.<span style="color: black;">oscradius</span><span style="color: black;">&#41;</span>
			<span style="color: #008000;">self</span>.<span style="color: black;">server</span>.<span style="color: black;">add_method</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/mp/zoom&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'f'</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">self</span>.<span style="color: black;">osczoom</span><span style="color: black;">&#41;</span>
			<span style="color: #008000;">self</span>.<span style="color: black;">server</span>.<span style="color: black;">add_method</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/mp/rotate&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'f'</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">self</span>.<span style="color: black;">oscrotate</span><span style="color: black;">&#41;</span>
			gobject.<span style="color: black;">timeout_add</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">20</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">self</span>.<span style="color: black;">pollcheck</span><span style="color: black;">&#41;</span>
			created <span style="color: #66cc66;">=</span> <span style="color: #008000;">True</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> oscradius<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> path<span style="color: #66cc66;">,</span> args<span style="color: black;">&#41;</span>:
        adj <span style="color: #66cc66;">=</span> <span style="color: #008000;">self</span>.<span style="color: black;">app</span>.<span style="color: black;">brush_adjustment</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'radius_logarithmic'</span><span style="color: black;">&#93;</span>
        adj.<span style="color: black;">set_value</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> oscv<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> path<span style="color: #66cc66;">,</span> args<span style="color: black;">&#41;</span>:
        h<span style="color: #66cc66;">,</span> s<span style="color: #66cc66;">,</span> v <span style="color: #66cc66;">=</span> <span style="color: #008000;">self</span>.<span style="color: black;">app</span>.<span style="color: black;">brush</span>.<span style="color: black;">get_color_hsv</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        v <span style="color: #66cc66;">=</span> args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> v <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">0.005</span>: v <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0.005</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> v <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">1.0</span>: v <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1.0</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">app</span>.<span style="color: black;">brush</span>.<span style="color: black;">set_color_hsv</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>h<span style="color: #66cc66;">,</span> s<span style="color: #66cc66;">,</span> v<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> osczoom<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> path<span style="color: #66cc66;">,</span> args<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">tdw</span>.<span style="color: black;">set_zoom</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> oscrotate<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> path<span style="color: #66cc66;">,</span> args<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">tdw</span>.<span style="color: black;">set_rotation</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> pollcheck<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">server</span>.<span style="color: black;">recv</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#41;</span>        <span style="color: #008000;">self</span>.<span style="color: black;">finished</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">False</span>
        Stroke.<span style="color: black;">serial_number</span> +<span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">serial_number</span> <span style="color: #66cc66;">=</span> Stroke.<span style="color: black;">serial_number</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span></pre></td></tr></table></div>

<p>MyPaint: share/mypaint/lib/stroke.py -> pyliblo client (send pressure, x, y to pd)</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> liblo<span style="color: #66cc66;">,</span> <span style="color: #dc143c;">sys</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">target</span> <span style="color: #66cc66;">=</span> liblo.<span style="color: black;">Address</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1234</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> record_event<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> dtime<span style="color: #66cc66;">,</span> x<span style="color: #66cc66;">,</span> y<span style="color: #66cc66;">,</span> pressure<span style="color: #66cc66;">,</span> xtilt<span style="color: #66cc66;">,</span>ytilt<span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">tmp_event_list</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>dtime<span style="color: #66cc66;">,</span> x<span style="color: #66cc66;">,</span> y<span style="color: #66cc66;">,</span> pressure<span style="color: #66cc66;">,</span> xtilt<span style="color: #66cc66;">,</span>ytilt<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        liblo.<span style="color: black;">send</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">target</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;/mypaint/pressure&quot;</span><span style="color: #66cc66;">,</span> pressure<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>PureData patch:<br />
<a href="http://www.workinprogress.ca/wp-content/uploads/bridgemypaint.pd"><img src="http://www.workinprogress.ca/wp-content/uploads/bridgepd-300x214.png" alt="bridgepd" width="300" height="214" class="alignnone size-medium wp-image-1753" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/theremin-a-crayon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>heavy box</title>
		<link>http://www.workinprogress.ca/heavy-box/</link>
		<comments>http://www.workinprogress.ca/heavy-box/#comments</comments>
		<pubDate>Mon, 14 Jan 2013 01:21:31 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Pure Data]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=1609</guid>
		<description><![CDATA[NFAQ how heavy? 32lb (14.5 kg) roughly a medium-sized dog what are you going to do with it? a centralized place for my digit/art project and my analog output. think of it as an effects unit or dsp in a box, but it&#8217;s also a silent computer with good processing power (as the time of [...]]]></description>
				<content:encoded><![CDATA[
<a href='http://www.workinprogress.ca/heavy-box/hcside/' title='hcside'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/hcside-150x150.jpg" class="attachment-thumbnail" alt="hcside" /></a>
<a href='http://www.workinprogress.ca/heavy-box/hbtop/' title='hbtop'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/hbtop-150x150.jpg" class="attachment-thumbnail" alt="hbtop" /></a>
<a href='http://www.workinprogress.ca/heavy-box/hbcompute/' title='hbcompute'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/hbcompute-150x150.jpg" class="attachment-thumbnail" alt="hbcompute" /></a>
<a href='http://www.workinprogress.ca/heavy-box/hbsoundcard/' title='hbsoundcard'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/hbsoundcard-150x150.jpg" class="attachment-thumbnail" alt="hbsoundcard" /></a>
<a href='http://www.workinprogress.ca/heavy-box/hbbottom/' title='hbbottom'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/hbbottom-150x150.jpg" class="attachment-thumbnail" alt="hbbottom" /></a>
<a href='http://www.workinprogress.ca/heavy-box/hbzen/' title='hbzen'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/hbzen-150x150.jpg" class="attachment-thumbnail" alt="hbzen" /></a>

<h3 style="color: #0A73A3;">NFAQ</h3>
<p><strong>how heavy?</strong><br />
32lb (14.5 kg) roughly a <a href="http://en.wikipedia.org/wiki/Orders_of_magnitude_(mass)">medium-sized dog</a></p>
<p><strong>what are you going to do with it?</strong><br />
a centralized place for my digit/art project and my analog output. think of it as an effects unit or dsp in a box, but it&#8217;s also a silent computer with good processing power (as the time of this writing). the main project is to <a href="http://vimeo.com/14059272">remix videos</a> on the fly while playing an instrument.</p>
<p><strong>what os/software are you using?</strong><br />
ubuntu studio with a low-latency kernel; pure data (effect rack, video player); sooperlooper (looping station); control (osc android application) all open source project</p>
<p><strong>what kind of wood did you use?</strong><br />
<a href="http://en.wikipedia.org/wiki/Aucoumea_klaineana">okoumé</a> (marine plywood). it&#8217;s a light wood and i was able to cut it with a x-acto!</p>
<p><strong>i want more information</strong><br />
sure! source of the project (mainly related to the electronics) are <a href="http://www.workinprogress.ca/projects/heavy-box">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/heavy-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>puredata on a tablet</title>
		<link>http://www.workinprogress.ca/puredata-tablet/</link>
		<comments>http://www.workinprogress.ca/puredata-tablet/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 04:14:45 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Pure Data]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=1522</guid>
		<description><![CDATA[here&#8217;s a short video showing puredata running on a ARM v7 / Cortex-A9 tablet (Zenithink c71 aka uPad: 1ghz, 512mb ram). i got this tablet for 144$ CAD. it is possible to connect an arduino to it (via USB) so anyone can &#8220;extend it&#8221; with sensors and such. there&#8217;s also a bluetooth / wifi and [...]]]></description>
				<content:encoded><![CDATA[<p>here&#8217;s a short video showing puredata running on a ARM v7 / Cortex-A9 tablet (Zenithink c71 aka uPad: 1ghz, 512mb ram). i got this tablet for 144$ CAD. it is possible to connect an arduino to it (via USB) so anyone can &#8220;extend it&#8221; with sensors and such. there&#8217;s also a bluetooth / wifi and a 5 points touchscreen. right now alsa is not working (start pd with -oss) and the video driver (mali) is not accelerated.</p>
<p>thanks to xllamas for sharing the <a href="http://www.slatedroid.com/topic/31075-linux-on-the-zt-280-c71/page__p__341999#entry341999">information</a> and also the <a href="http://makeplaylive.com/">http://makeplaylive.com/</a> for the initial work.</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/C-P7Y8bz0bg?rel=0&#038;wmode=transparent" frameborder="0" allowfullscreen></iframe></p>
<p>i am currently working on a new prototype of &#8220;<a href="http://www.workinprogress.ca/projects/guitare-a-crayon/">la guitar à crayon</a>&#8221; called &#8220;string pad&#8221;. bought a guitar kit for 160$. all set to start working on this project.</p>
<p><img src="http://www.workinprogress.ca/wp-content/uploads/stringpad.jpg" alt="" title="stringpad" width="640" height="427" class="alignnone size-medium wp-image-1532" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/puredata-tablet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Online Speech Recognition for Dictation</title>
		<link>http://www.workinprogress.ca/online-speech-recognition-dictation/</link>
		<comments>http://www.workinprogress.ca/online-speech-recognition-dictation/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 05:28:15 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=1231</guid>
		<description><![CDATA[I&#8217;m working on the integration of kiku (voice recognition to control your OS) to Vinux (Linux for the visually impaired). For now the feedback about kiku is great, but one thing people wants is a solution for dictation (that is, speech to text). kiku could be use for that task, but sadly there is no [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.workinprogress.ca/KIKU/dictation.php"><img src="http://www.workinprogress.ca/wp-content/uploads/onlinespeechrecognitiondictation-1024x554.png" alt="" title="onlinespeechrecognitiondictation" width="512" height="277" class="alignnone size-large wp-image-1233" /></a></p>
<p>I&#8217;m working on the integration of <a href="http://www.workinprogress.ca/kiku/about">kiku</a> <em>(voice recognition to control your OS)</em> to <a href="http://vinuxproject.org/">Vinux</a> <em>(Linux for the visually impaired)</em>. For now the feedback about kiku is great, but one thing people wants is a solution for dictation (that is, speech to text). kiku could be use for that task, but sadly there is no good (accurate) acoustic model available under GPL (Voxforge is a good start, but not there yet &#8211; please <a href="http://www.voxforge.org/home/read">contribute</a>).</p>
<p>So i came up with this <a href="http://www.workinprogress.ca/KIKU/dictation.php">online speech recognition for dictation</a> solution to overcome this limitation. Speak in different languages, spell check, translate and text to speech all in one place. You&#8217;ll need <a href="http://www.google.com/chrome">Google Chrome</a> and a microphone.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="540" height="405" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/D5rNrfufHmw&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" /><param name="allowfullscreen" value="true" /><param name="wmode" value="transparent" /><embed type="application/x-shockwave-flash" width="540" height="405" src="http://www.youtube.com/v/D5rNrfufHmw&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" wmode="transparent" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/online-speech-recognition-dictation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>p-waves physical feedback</title>
		<link>http://www.workinprogress.ca/p-waves-physical-feedback/</link>
		<comments>http://www.workinprogress.ca/p-waves-physical-feedback/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 17:16:22 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=1136</guid>
		<description><![CDATA[on march 11 my apartment in tokyo was shook by an earthquake of magnitude 9.0: since i don&#8217;t have a mobile phone (i must be the only one in japan without a keitai) i wasn&#8217;t aware of the incoming earthquake and my software was useless (being alert 10 minutes after the earthquake): by detecting the [...]]]></description>
				<content:encoded><![CDATA[<p>on march 11 my apartment in tokyo was shook by an earthquake of magnitude 9.0:</p>
<p><iframe title="YouTube video player" width="560" height="349" src="http://www.youtube.com/embed/i6U-N0W5Zkc?rel=0&#038;wmode=transparent" frameborder="0" allowfullscreen></iframe></p>
<p>since i don&#8217;t have a mobile phone (i must be the only one in japan without a keitai) i wasn&#8217;t aware of the incoming earthquake and my software was useless (being alert 10 minutes after the earthquake):</p>
<p><iframe src="http://player.vimeo.com/video/13615727" width="560" height="315" frameborder="0"></iframe></p>
<p>by detecting the <a href="http://en.wikipedia.org/wiki/Seismic_wave#P-waves">primary waves</a> we know in how many seconds (depending on the epicenter location) an earthquake will occur. i don&#8217;t know if it&#8217;s possible to build a p waves monitoring device (anyone?), but for now i&#8217;m using a <a href="http://www.estrat.co.jp/download.html">free software</a> (windows &#038; japanese only) that send me an alert (no hardware required).</p>
<p>connecting the software to a microcontroller was not that hard, but since i don&#8217;t want to boot in windows just for monitoring the p waves i had to hack little. grosso modo: <a href="http://www.virtualbox.org/">virtual box</a> (windows in linux) -> <a href="http://www.autoitscript.com/site/autoit/">autoit</a> (checking for a p waves popup) -> create file <- linux bash checking for new file -> send serial command to arduino -> physical feedback.</p>
<p><iframe title="YouTube video player" width="560" height="349" src="http://www.youtube.com/embed/oiP9QCS-8ig?rel=0&#038;wmode=transparent" frameborder="0" allowfullscreen></iframe></p>
<p><strong>please make a donation to the japanese red cross society</strong></p>
<p><a href="http://www.google.com/crisisresponse/japanquake2011.html"><img border="0" src="http://www.redcross.org/www-files/psabanners/PacificTsunami/468x60.jpg" alt="Japan Earthquake and Pacific Tsunami"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/p-waves-physical-feedback/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vibrating art</title>
		<link>http://www.workinprogress.ca/vibrating-art/</link>
		<comments>http://www.workinprogress.ca/vibrating-art/#comments</comments>
		<pubDate>Sun, 19 Dec 2010 18:23:16 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=876</guid>
		<description><![CDATA[the idea is simple: take an old electric toothbrush; add a led and a vibrator; shape something around it; i am using polycaprolactone (FDA approuved). the schematic is pretty simple, but i had to play with the capacitor and inductor to get more power into the vibrator. it&#8217;s overkill to use an attiny for cycling [...]]]></description>
				<content:encoded><![CDATA[<p>the idea is simple:</p>
<ul>
<li>take an old electric toothbrush;</li>
<li>add a led and a vibrator;</li>
<li>shape something around it;</li>
</ul>
<p>i am using polycaprolactone (FDA approuved). the schematic is pretty simple, but i had to play with the capacitor and inductor to get more power into the vibrator. it&#8217;s overkill to use an attiny for cycling the colors of the led (i didn&#8217;t know that you can buy RGB led with built-in pwm). even so, i am sharing the small code, maybe it can be useful to someone. since i am using an electric toothbrush there&#8217;s no physical connection to recharge it, thus completely waterproof. i will need to remelt the polycaprolactone to change the battery someday.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="540" height="405" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/vE1pPWRUmbs&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" /><param name="allowfullscreen" value="true" /><param name="wmode" value="transparent" /><embed type="application/x-shockwave-flash" width="540" height="405" src="http://www.youtube.com/v/vE1pPWRUmbs&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" wmode="transparent" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>

<a href='http://www.workinprogress.ca/vibrating-art/va_bundle/' title='va_bundle'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/va_bundle-150x150.jpg" class="attachment-thumbnail" alt="va_bundle" /></a>
<a href='http://www.workinprogress.ca/vibrating-art/va_onrecharge/' title='va_onrecharge'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/va_onrecharge-150x150.jpg" class="attachment-thumbnail" alt="va_onrecharge" /></a>
<a href='http://www.workinprogress.ca/vibrating-art/va_schematic/' title='va_schematic'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/va_schematic-150x150.jpg" class="attachment-thumbnail" alt="va_schematic" /></a>
<a href='http://www.workinprogress.ca/vibrating-art/va_withvl/' title='va_withvl'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/va_withvl-150x150.jpg" class="attachment-thumbnail" alt="va_withvl" /></a>

<p></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="c" style="font-family:monospace;"> <span style="color: #339933;">#define F_CPU 9600000UL</span>
 <span style="color: #339933;">#include &lt;avr/io.h&gt;</span>
 <span style="color: #339933;">#include &lt;util/delay.h&gt;</span>
 <span style="color: #339933;">#define LED PB0</span>
 <span style="color: #339933;">#define LED2 PB1</span>
 <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #993333;">int</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
	 DDRB <span style="color: #339933;">=</span> <span style="color: #208080;">0xff</span><span style="color: #339933;">;</span>
	 TCCR0A <span style="color: #339933;">|=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> COM0A1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> COM0A0<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> COM0B1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> COM0B0<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> WGM01<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> WGM00<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// WGM01 - WGM00 (set fast PWM)</span>
	 OCR0A <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// initialize Output Compare Register A to 0</span>
	 OCR0B <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
	 TCCR0B <span style="color: #339933;">|=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> CS01<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Start timer at Fcpu / 256</span>
&nbsp;
	 <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">;;</span><span style="color: #009900;">&#41;</span>
	 <span style="color: #009900;">&#123;</span>
		 <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">255</span> <span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// For loop (Up counter 0 - 255)</span>
		 <span style="color: #009900;">&#123;</span>
			  OCR0A <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Update Output Compare Register (PWM 0 - 255)</span>
			 _delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #009900;">&#125;</span>
		 <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">255</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">;</span> i<span style="color: #339933;">--</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// For loop (down counter 255 - 0 )</span>
		 <span style="color: #009900;">&#123;</span>
			 OCR0B <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Update Output Compare Register (PWM 0 - 255)</span>
			 _delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #009900;">&#125;</span>
		 <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">255</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">;</span> i<span style="color: #339933;">--</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// For loop (down counter 255 - 0 )</span>
		 <span style="color: #009900;">&#123;</span>
			  OCR0A <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Update Output Compare Register (PWM 0 - 255)</span>
			 _delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #009900;">&#125;</span>
		 <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">255</span> <span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// For loop (Up counter 0 - 255)</span>
		 <span style="color: #009900;">&#123;</span>
			  OCR0B <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Update Output Compare Register (PWM 0 - 255)</span>
			 _delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		 <span style="color: #009900;">&#125;</span>
	 <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/vibrating-art/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>video tour of akihabara</title>
		<link>http://www.workinprogress.ca/video-tour-of-akihabara/</link>
		<comments>http://www.workinprogress.ca/video-tour-of-akihabara/#comments</comments>
		<pubDate>Sat, 25 Sep 2010 02:55:29 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=820</guid>
		<description><![CDATA[if you are curious to see the electronic town (Akihabara) in Tokyo:]]></description>
				<content:encoded><![CDATA[<p>if you are curious to see the electronic town (Akihabara) in Tokyo:<br />
<a href="http://www.workinprogress.ca/akihabara"><img class="alignnone size-full wp-image-821" title="akihabara" src="http://www.workinprogress.ca/wp-content/uploads/akihabara.jpg" alt="" width="533" height="454" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/video-tour-of-akihabara/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Manabu-san</title>
		<link>http://www.workinprogress.ca/manabu-san/</link>
		<comments>http://www.workinprogress.ca/manabu-san/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 13:13:44 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=790</guid>
		<description><![CDATA[I wrote this software (based on JMDict) to learn new words in japanese. It&#8217;s written in C++ (wxWidgets) and use sqlite3. A compiled version for Windows is available for download (with installer / uninstaller). I am sharing the source, but i won&#8217;t recommend to learn from it (a cobe::blocks project). Here&#8217;s a screenshot in Windows: Here&#8217;s a [...]]]></description>
				<content:encoded><![CDATA[<p>I wrote this software (based on<a href="http://www.csse.monash.edu.au/~jwb/j_jmdict.html" target="_blank"> JMDict</a>) to learn new words in japanese. It&#8217;s written in C++ (<a href="http://www.wxwidgets.org/" target="_blank">wxWidgets</a>) and use <a href="http://www.sqlite.org/" target="_blank">sqlite3</a>. A compiled version for Windows is available for download (with installer / uninstaller). I am sharing the source, but i won&#8217;t recommend to learn from it (a <a href="http://www.codeblocks.org/" target="_blank">cobe::blocks</a> project).</p>
<p>Here&#8217;s a screenshot in Windows:</p>
<p><a href="http://www.workinprogress.ca/wp-content/uploads/manabu-san.jpg"></a><a href="http://www.workinprogress.ca/wp-content/uploads/manabu-san.jpg"><img class="alignnone size-large wp-image-791" title="manabu-san" src="http://www.workinprogress.ca/wp-content/uploads/manabu-san-1024x710.jpg" alt="" width="500" height="347" /></a></p>
<p>Here&#8217;s a screenshot in Ubuntu / Gtk:</p>
<p><a href="http://www.workinprogress.ca/wp-content/uploads/manabu-san-linux.jpg"><img class="alignnone size-large wp-image-804" title="manabu-san-linux" src="http://www.workinprogress.ca/wp-content/uploads/manabu-san-linux-1024x692.jpg" alt="" width="500" height="338" /></a></p>
<p><a href="http://www.workinprogress.ca/wp-content/uploads/setup.exe">Download the installer</a> (for Windows, beta)<br />
<a href="http://www.workinprogress.ca/wp-content/uploads/manabu_src.zip">Download the source</a> (code::blocks)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/manabu-san/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cheap avr intervalometer</title>
		<link>http://www.workinprogress.ca/avr-intervalometer/</link>
		<comments>http://www.workinprogress.ca/avr-intervalometer/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 08:38:21 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Blender]]></category>
		<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=755</guid>
		<description><![CDATA[this project is obsolete if you own a Canon supported by http://wiki.magiclantern.fmopen source tool that runs from the SD/CF card at camera startup. now that i have a digital camera (but my heart will always belong to film-based photography) i can do time lapse photography. sadly the firmware of my camera isn&#8217;t supporting this feature, [...]]]></description>
				<content:encoded><![CDATA[<p><strong>this project is obsolete if you own a Canon supported by <a href="http://wiki.magiclantern.fm">http://wiki.magiclantern.fm</a></strong><br /><em>open source tool that runs from the SD/CF card at camera startup</em>.</p>
<p>now that i have a digital camera (but my heart will always belong to film-based photography) i can do time lapse photography. sadly the firmware of my camera isn&#8217;t supporting this feature, so i had to build an <a href="http://en.wikipedia.org/wiki/Intervalometer" target="_blank">intervalometer</a>. i didn&#8217;t want to use an arduino (overkill &amp; pricy), so i went with an attiny45, a generic optocoupler, a voltage regulator and a potentiometer for adjusting the timer from 1 second to 1 minute.</p>
<p>i just found out that it&#8217;s possible to power the avr from the camera (focus ring). have a look at this complete and small solution: <a href="http://www.doc-diy.net/photo/hdr-jack/">http://www.doc-diy.net/photo/hdr-jack/</a></p>

<a href='http://www.workinprogress.ca/avr-intervalometer/intervalometer_1/' title='intervalometer_1'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/intervalometer_1-150x150.jpg" class="attachment-thumbnail" alt="intervalometer_1" /></a>
<a href='http://www.workinprogress.ca/avr-intervalometer/intervalometer_3/' title='intervalometer_3'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/intervalometer_3-150x150.jpg" class="attachment-thumbnail" alt="intervalometer_3" /></a>
<a href='http://www.workinprogress.ca/avr-intervalometer/avr_intervalometer_schematic/' title='avr_intervalometer_schematic'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/avr_intervalometer_schematic-150x150.png" class="attachment-thumbnail" alt="avr_intervalometer_schematic" /></a>


<div class="wp_syntax"><table><tr><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Intervalometer from 1 second to 1 minute</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Author: Patrick Sebastien Coulombe</span>
<span style="color: #666666; font-style: italic;">//Website: www.workinprogress.ca</span>
<span style="color: #666666; font-style: italic;">//Date: 2010-07-24</span>
&nbsp;
<span style="color: #339933;">#define F_CPU 8000000</span>
<span style="color: #339933;">#include &lt;avr/io.h&gt;</span>
<span style="color: #339933;">#include &lt;util/delay.h&gt;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// use PB2 for led, pin 7</span>
<span style="color: #339933;">#define LED_BIT 2</span>
<span style="color: #666666; font-style: italic;">// select ADC2, PB4, pin 3</span>
<span style="color: #339933;">#define CHANNEL 2</span>
<span style="color: #666666; font-style: italic;">// shutter on (in ms)</span>
<span style="color: #339933;">#define HOLD 300 </span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Return the 10bit value of the selected adc channel.</span>
<span style="color: #993333;">uint16_t</span> get_adc<span style="color: #009900;">&#40;</span><span style="color: #993333;">uint8_t</span> channel<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// ADC setup</span>
	ADCSRA <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> ADEN<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> ADPS1<span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> ADPS0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// select channel</span>
	ADMUX <span style="color: #339933;">=</span> channel<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// warm up the ADC, discard the first conversion</span>
	ADCSRA <span style="color: #339933;">|=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> ADSC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>ADCSRA <span style="color: #339933;">&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> ADSC<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
	ADCSRA <span style="color: #339933;">|=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> ADSC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// start single conversion</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>ADCSRA <span style="color: #339933;">&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> ADSC<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// wait until conversion is done</span>
&nbsp;
	<span style="color: #b1b100;">return</span> ADCW<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Scale</span>
<span style="color: #993333;">long</span> map<span style="color: #009900;">&#40;</span><span style="color: #993333;">long</span> x<span style="color: #339933;">,</span> <span style="color: #993333;">long</span> in_min<span style="color: #339933;">,</span> <span style="color: #993333;">long</span> in_max<span style="color: #339933;">,</span> <span style="color: #993333;">long</span> out_min<span style="color: #339933;">,</span> <span style="color: #993333;">long</span> out_max<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">-</span> in_min<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>out_max <span style="color: #339933;">-</span> out_min<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span>in_max <span style="color: #339933;">-</span> in_min<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> out_min<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Main program</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// vars</span>
	<span style="color: #993333;">uint16_t</span> adcvalue <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
	<span style="color: #993333;">uint16_t</span> i<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// define LED as outputs</span>
	DDRB <span style="color: #339933;">|=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> LED_BIT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	
&nbsp;
		<span style="color: #666666; font-style: italic;">//release the shutter</span>
		PORTB <span style="color: #339933;">|=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> LED_BIT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//exposure length</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>HOLD<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			_delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
		PORTB <span style="color: #339933;">&amp;=</span> ~<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #339933;">&lt;&lt;</span> LED_BIT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//interval time (using a potentiometer to adjust)</span>
		adcvalue <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>get_adc<span style="color: #009900;">&#40;</span>CHANNEL<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1023</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		adcvalue <span style="color: #339933;">=</span> adcvalue <span style="color: #339933;">*</span> <span style="color: #0000dd;">1000</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//one way to achieve long delay</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>adcvalue<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			_delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Time lapse test (3 hours) from my balcony.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="540" height="405" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/mKEQjxkCzD4&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="540" height="405" src="http://www.youtube.com/v/mKEQjxkCzD4&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" allowscriptaccess="always" allowfullscreen="true" wmode="transparent"></embed></object></p>
<p>I used Blender for making the tilt / shift effect. Here&#8217;s the <a href="http://www.workinprogress.ca/wp-content/uploads/blendertiltshift.tar.gz">source</a> of the Blender file.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="540" height="405" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/qpac5wb7mAE&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="540" height="405" src="http://www.youtube.com/v/qpac5wb7mAE&amp;hl=en_US&amp;fs=1?rel=0&amp;hd=1" allowscriptaccess="always" allowfullscreen="true" wmode="transparent"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/avr-intervalometer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>singing birds</title>
		<link>http://www.workinprogress.ca/singing-birds/</link>
		<comments>http://www.workinprogress.ca/singing-birds/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 04:36:59 +0000</pubDate>
		<dc:creator>psc</dc:creator>
				<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://www.workinprogress.ca/?p=706</guid>
		<description><![CDATA[10 watts amplifier with built-in 16-bit / 48kHz RIFF-WAVE player (music on a SD-CARD). 2 servos for controlling the beaks. I did this project mostly to learn stuff. The result is a bit stupid. VIDEO: PHOTOS: Schematic &#038; Board (Kicad) How to filter PWM for music sd player source code /*---------------------------------------------------------------*/ /* 8-pin SD audio [...]]]></description>
				<content:encoded><![CDATA[<p>10 watts amplifier with built-in 16-bit / 48kHz RIFF-WAVE player (<a href="http://elm-chan.org/works/sd8p/report.html" target="_blank">music on a SD-CARD</a>). 2 servos for controlling the beaks. I did this project mostly to learn stuff. The result is a bit stupid.</p>
<p><strong>VIDEO:</strong><br />
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/rEM_cyZhxQU?fs=1&amp;hl=en_US&amp;rel=0"></param><param name="wmode" value="transparent" /></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/rEM_cyZhxQU?fs=1&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" wmode="transparent" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p><strong>PHOTOS:</strong><br />

<a href='http://www.workinprogress.ca/singing-birds/p4120089/' title='passive crossover'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/P4120089-150x150.jpg" class="attachment-thumbnail" alt="passive crossover" /></a>
<a href='http://www.workinprogress.ca/singing-birds/p4130093/' title='back - 2 mini servo'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/P4130093-150x150.jpg" class="attachment-thumbnail" alt="back - 2 mini servo" /></a>
<a href='http://www.workinprogress.ca/singing-birds/p4130094/' title='single-side homemade PCB'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/P4130094-150x150.jpg" class="attachment-thumbnail" alt="single-side homemade PCB" /></a>
<a href='http://www.workinprogress.ca/singing-birds/p4130095/' title='front'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/P4130095-150x150.jpg" class="attachment-thumbnail" alt="front" /></a>
<a href='http://www.workinprogress.ca/singing-birds/blender/' title='i used blender like a CAD software'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/blender-150x150.jpg" class="attachment-thumbnail" alt="i used blender like a CAD software" /></a>
<a href='http://www.workinprogress.ca/singing-birds/board/' title='attiny85 - attiny24 - tpa1517ne - pwm filter - opamp'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/board-150x150.jpg" class="attachment-thumbnail" alt="attiny85 - attiny24 - tpa1517ne - pwm filter - opamp" /></a>
<a href='http://www.workinprogress.ca/singing-birds/schematic-2/' title='schematic - done in kicad'><img width="150" height="150" src="http://www.workinprogress.ca/wp-content/uploads/schematic1-150x150.jpg" class="attachment-thumbnail" alt="schematic - done in kicad" /></a>
</p>
<p>
<a href="http://www.workinprogress.ca/wp-content/uploads/sb.zip">Schematic &#038; Board</a> (Kicad)<br />
<a href="http://www.workinprogress.ca/filtering-pwm-for-music/">How to filter PWM for music</a>
</p>
<p>sd player source code</p>
<p><pre><pre class="brush:c">
/*---------------------------------------------------------------*/
/* 8-pin SD audio player R0.02&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (C)ChaN, 2009 */
/*---------------------------------------------------------------*/

#include &lt;avr/io.h&gt;
#include &lt;avr/interrupt.h&gt;
#include &lt;avr/sleep.h&gt;
#include &lt;avr/wdt.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &quot;diskio.h&quot;
#include &quot;pff.h&quot;

char strbuff[10];
unsigned int position = 0;
unsigned long count = 0;
unsigned int nbwave = 0;

#define FCC(c1,c2,c3,c4)&nbsp;&nbsp;(((DWORD)c4&lt;&lt;24)+((DWORD)c3&lt;&lt;16)+((WORD)c2&lt;&lt;8)+(BYTE)c1)&nbsp;&nbsp;/* FourCC */

/*---------------------------------------------------------*/
/* Work Area&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */
/*---------------------------------------------------------*/

volatile BYTE FifoRi, FifoWi, FifoCt;&nbsp;&nbsp;/* FIFO controls */

BYTE Buff[256];&nbsp;&nbsp;&nbsp;&nbsp;/* Wave output FIFO */

FATFS fs;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* File system object */
DIR dir;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Directory object */
FILINFO fno;&nbsp;&nbsp;&nbsp;&nbsp;/* File information */

WORD rb;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Return value. Put this here to avoid bugs of avr-gcc */

EMPTY_INTERRUPT(WDT_vect);

/*---------------------------------------------------------*/

static
DWORD load_header (void)&nbsp;&nbsp;/* 0:Invalid format, 1:I/O error, &gt;1:Number of samples */
{
&nbsp;&nbsp;DWORD fcc, sz;
&nbsp;&nbsp;UINT i;
&nbsp;&nbsp;FRESULT res;

&nbsp;&nbsp;res = pf_read(Buff, 256, &amp;rb);&nbsp;&nbsp;&nbsp;&nbsp;/* Load file header (256 bytes) */
&nbsp;&nbsp;if (res) return 1;

&nbsp;&nbsp;if (rb != 256 || LD_DWORD(Buff+8) != FCC(&#039;W&#039;,&#039;A&#039;,&#039;V&#039;,&#039;E&#039;)) return 0;

&nbsp;&nbsp;i = 12;
&nbsp;&nbsp;while (i &lt; 200) {
&nbsp;&nbsp;&nbsp;&nbsp;fcc = LD_DWORD(&amp;Buff[i]);&nbsp;&nbsp;/* FCC */
&nbsp;&nbsp;&nbsp;&nbsp;sz = LD_DWORD(&amp;Buff[i+4]);&nbsp;&nbsp;/* Chunk size */
&nbsp;&nbsp;&nbsp;&nbsp;i += 8;
&nbsp;&nbsp;&nbsp;&nbsp;switch (fcc) {

&nbsp;&nbsp;&nbsp;&nbsp;case FCC(&#039;f&#039;,&#039;m&#039;,&#039;t&#039;,&#039; &#039;) :&nbsp;&nbsp;&nbsp;&nbsp;/* &#039;fmt &#039; chunk */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (sz &gt; 100 || sz &lt; 16)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Check chunk size */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Buff[i+0] != 1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Check coding type (1) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Buff[i+2] != 1 &amp;&amp; Buff[i+2] != 2)&nbsp;&nbsp;/* Check channels (1/2) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GPIOR0 = Buff[i+2];&nbsp;&nbsp;&nbsp;&nbsp;/* Channel flag */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (Buff[i+14] != 8 &amp;&amp; Buff[i+14] != 16)&nbsp;&nbsp;/* Check resolution (8/16) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GPIOR0 |= Buff[i+14];&nbsp;&nbsp;/* Resolution flag */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OCR0A = (BYTE)(F_CPU / 8 / LD_WORD(&amp;Buff[i+4])) - 1;&nbsp;&nbsp;/* Sampling freq */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;case FCC(&#039;f&#039;,&#039;a&#039;,&#039;c&#039;,&#039;t&#039;) :&nbsp;&nbsp;&nbsp;&nbsp;/* &#039;fact&#039; chunk (skip) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;

&nbsp;&nbsp;&nbsp;&nbsp;case FCC(&#039;d&#039;,&#039;a&#039;,&#039;t&#039;,&#039;a&#039;) :&nbsp;&nbsp;&nbsp;&nbsp;/* &#039;data&#039; chunk (start to play) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fs.fptr = i;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return sz;

&nbsp;&nbsp;&nbsp;&nbsp;default :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Unknown chunk (error) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;i += sz;
&nbsp;&nbsp;}

&nbsp;&nbsp;return 0;
}

static
UINT play (
&nbsp;&nbsp;const char *fn
)
{
&nbsp;&nbsp;DWORD sz;
&nbsp;&nbsp;FRESULT res;
&nbsp;&nbsp;BYTE sw;
&nbsp;&nbsp;WORD btr;

&nbsp;&nbsp;if ((res = pf_open(fn)) == FR_OK) {
&nbsp;&nbsp;&nbsp;&nbsp;sz = load_header();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Load file header */
&nbsp;&nbsp;&nbsp;&nbsp;if (sz &lt; 256) return (UINT)sz;

&nbsp;&nbsp;&nbsp;&nbsp;if (!TCCR1) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Enable audio out if not enabled */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PLLCSR = 0b00000110;&nbsp;&nbsp;/* Select PLL clock for TC1.ck */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GTCCR =&nbsp;&nbsp;0b01100000;&nbsp;&nbsp;/* Enable TC1.OCB as PWM out (L-ch) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OCR1B = 128; OCR1A = 128;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TCCR1 = STEREO ? 0b01100001 : 0b00000001;&nbsp;&nbsp;/* Start TC1 with TC1.OCA is enabled as PWM out (R-ch) */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TCCR0A = 0b00000010;&nbsp;&nbsp;/* Enable TC0.ck = 2MHz as interval timer */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TCCR0B = 0b00000010;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TIMSK = _BV(OCIE0A);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;FifoCt = 0; FifoRi = 0; FifoWi = 0;&nbsp;&nbsp;&nbsp;&nbsp;/* Reset FIFO */
&nbsp;&nbsp;&nbsp;&nbsp;pf_read(0, 512 - fs.fptr, &amp;rb);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Snip sector unaligned part */
&nbsp;&nbsp;&nbsp;&nbsp;sz -= rb;

&nbsp;&nbsp;&nbsp;&nbsp;sw = 1;&nbsp;&nbsp;&nbsp;&nbsp;/* Button status flag */
&nbsp;&nbsp;&nbsp;&nbsp;do {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Forward audio data */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;btr = (sz &gt; 1024) ? 1024 : (WORD)sz;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;res = pf_read(0, btr, &amp;rb);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (res != FR_OK || btr != rb) break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sz -= rb;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Check button down and break on button down */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sw &lt;&lt;= 1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//if (bit_is_clear(PINB, 0) &amp;&amp; ++sw == 1) break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (bit_is_clear(PINB, 0) &amp;&amp; ++sw == 1) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count = 0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do { 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count++;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wdt_reset();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} while (bit_is_clear(PINB, 0));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(count &gt; 500000) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position--;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position--;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wdt_reset();
&nbsp;&nbsp;&nbsp;&nbsp;} while (rb == 1024);&nbsp;&nbsp;/* Repeat until all data read */
&nbsp;&nbsp;}

&nbsp;&nbsp;while (FifoCt) ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Wait for FIFO empty */
&nbsp;&nbsp;OCR1A = 128; OCR1B = 128;

&nbsp;&nbsp;return res;
}

long smallrandom(long howbig)
{
&nbsp;&nbsp;if (howbig == 0) {
&nbsp;&nbsp;&nbsp;&nbsp;return 0;
&nbsp;&nbsp;}
&nbsp;&nbsp;return random() % howbig;
}

long rangerandom(long howsmall, long howbig)
{
&nbsp;&nbsp;if (howsmall &gt;= howbig) {
&nbsp;&nbsp;&nbsp;&nbsp;return howsmall;
&nbsp;&nbsp;}
&nbsp;&nbsp;long diff = howbig - howsmall;
&nbsp;&nbsp;return smallrandom(diff) + howsmall;
}

int main (void)
{
&nbsp;&nbsp;PORTB = 0b111011;&nbsp;&nbsp;&nbsp;&nbsp;/* Initialize port: - - H H H L H P */
&nbsp;&nbsp;DDRB&nbsp;&nbsp;= 0b111110;
&nbsp;&nbsp;
&nbsp;&nbsp;sei();
&nbsp;&nbsp;
&nbsp;&nbsp;//RANDOM (SEED)
&nbsp;&nbsp;unsigned long seednumber = 1;
&nbsp;&nbsp;unsigned char i;
&nbsp;&nbsp;ADCSRA |= (1 &lt;&lt; ADPS2) | (1 &lt;&lt; ADPS1) | (0 &lt;&lt; ADPS0);&nbsp;&nbsp;//ADC Prescalar set to 64 - 125kHz@8MHz
&nbsp;&nbsp;ADMUX |= (1 &lt;&lt; ADLAR);
&nbsp;&nbsp;ADCSRA |= (1 &lt;&lt; ADEN);&nbsp;&nbsp;// Enable ADC
&nbsp;&nbsp;&nbsp;&nbsp;for(i = 0; i &lt; 100; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;wdt_reset();
&nbsp;&nbsp;&nbsp;&nbsp;ADCSRA |= (1 &lt;&lt; ADSC);&nbsp;&nbsp;// Start A2D Conversions
&nbsp;&nbsp;&nbsp;&nbsp;while (ADCSRA &amp; (1 &lt;&lt; ADSC)); 
&nbsp;&nbsp;&nbsp;&nbsp;seednumber = seednumber + ADCH;
&nbsp;&nbsp;}
&nbsp;&nbsp;ADCSRA |= (0 &lt;&lt; ADATE);
&nbsp;&nbsp;ADCSRA |= (0 &lt;&lt; ADEN);&nbsp;&nbsp;// Disable ADC
&nbsp;&nbsp;&nbsp;&nbsp;ADCSRA |= (0 &lt;&lt; ADSC);&nbsp;&nbsp;// Stop A2D Conversions
&nbsp;&nbsp;
&nbsp;&nbsp;MCUSR = 0;
&nbsp;&nbsp;WDTCR = _BV(WDE) | 0b110;&nbsp;&nbsp;/* Enable WDT reset in timeout of 1s */

&nbsp;&nbsp;BYTE res;
&nbsp;&nbsp;//mount
&nbsp;&nbsp;do {
&nbsp;&nbsp;&nbsp;&nbsp;res = pf_mount(&amp;fs);
&nbsp;&nbsp;&nbsp;&nbsp;wdt_reset();
&nbsp;&nbsp;&nbsp;&nbsp;seednumber++;
&nbsp;&nbsp;} while (res != FR_OK);
&nbsp;&nbsp;
&nbsp;&nbsp;Buff[0] = 0;
&nbsp;&nbsp;do {
&nbsp;&nbsp;&nbsp;&nbsp;res = pf_opendir(&amp;dir, (char*)Buff);
&nbsp;&nbsp;&nbsp;&nbsp;wdt_reset();
&nbsp;&nbsp;&nbsp;&nbsp;seednumber++;
&nbsp;&nbsp;} while (res != FR_OK);
&nbsp;&nbsp;
&nbsp;&nbsp;//nb files
&nbsp;&nbsp;for (;;) {
&nbsp;&nbsp;&nbsp;&nbsp;res = pf_readdir(&amp;dir, &amp;fno);
&nbsp;&nbsp;&nbsp;&nbsp;if (res != FR_OK || fno.fname[0] == 0) break;
&nbsp;&nbsp;&nbsp;&nbsp;wdt_reset();
&nbsp;&nbsp;&nbsp;&nbsp;nbwave++;
&nbsp;&nbsp;&nbsp;&nbsp;seednumber++;
&nbsp;&nbsp;}
&nbsp;&nbsp;
&nbsp;&nbsp;srandom(seednumber);
&nbsp;&nbsp;//start with a random position
&nbsp;&nbsp;position = rangerandom(1, nbwave + 1);

&nbsp;&nbsp;for (;;) {
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;//limit
&nbsp;&nbsp;&nbsp;&nbsp;if(position &gt; (nbwave + 1)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position = 1;
&nbsp;&nbsp;&nbsp;&nbsp;} else if(position &lt; 1) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;position = 1;
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;//play
&nbsp;&nbsp;&nbsp;&nbsp;sprintf(strbuff,&quot;%d.wav&quot;, position);
&nbsp;&nbsp;&nbsp;&nbsp;play(strbuff);
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;//increment song
&nbsp;&nbsp;&nbsp;&nbsp;position++;

&nbsp;&nbsp;}
}
</pre></pre></p>
<p>servo source code</p>
<p><pre><pre class="brush:c">
#include &lt;avr/io.h&gt;
#include &lt;avr/interrupt.h&gt;
#include &lt;inttypes.h&gt;
#include &lt;avr/sleep.h&gt;
#include &lt;util/delay.h&gt; 

#define F_CPU 8000000
#define nop()&nbsp;&nbsp;__asm__ __volatile__(&quot;nop&quot;)

void wait100us(void) {
&nbsp;&nbsp;&nbsp;&nbsp;unsigned char i;
&nbsp;&nbsp;&nbsp;&nbsp;for(i = 0; i &lt; 100; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nop();
&nbsp;&nbsp;&nbsp;&nbsp;}
}

void Delay_ms(unsigned int t)

&nbsp;&nbsp;{
&nbsp;&nbsp; unsigned int i, aika;
&nbsp;&nbsp; aika = 140;

&nbsp;&nbsp; while(t--)
&nbsp;&nbsp;&nbsp;&nbsp;for(i = 0; i &lt; aika; i++)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(t==0) return;

&nbsp;&nbsp;} 

void adcinit (void) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// PRESCALER 128
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADCSRA |= (1 &lt;&lt; ADPS2) | (1 &lt;&lt; ADPS1) | (0 &lt;&lt; ADPS0);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// AUTO TRIGGER ENABLE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADCSRA |= (1 &lt;&lt; ADATE);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// VCC ref
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADMUX |= (0 &lt;&lt; REFS1) | (0 &lt;&lt; REFS0);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// RIGHT ADJUST
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADCSRB |= (0 &lt;&lt; ADLAR);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// CHANNEL 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADMUX |= (0 &lt;&lt; MUX5) | (0 &lt;&lt; MUX4) | (0 &lt;&lt; MUX3) | (0 &lt;&lt; MUX2) | (0 &lt;&lt; MUX1) | (1 &lt;&lt; MUX0);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// FREE RUNNING MODE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADCSRB |= (0 &lt;&lt; ADTS2) | (0 &lt;&lt; ADTS1) | (0 &lt;&lt; ADTS0);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ENABLE ADC
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADCSRA |= (1 &lt;&lt; ADEN);

&nbsp;&nbsp;&nbsp;&nbsp;// PORT A: INPUT
&nbsp;&nbsp;&nbsp;&nbsp;DDRA = 0x00;
&nbsp;&nbsp;&nbsp;&nbsp;PORTA = 0x00;

}

void pwminit (void) {
&nbsp;&nbsp;&nbsp;&nbsp;// disable PWM while configuring it
&nbsp;&nbsp;&nbsp;&nbsp;TCCR1A = 0;

&nbsp;&nbsp;&nbsp;&nbsp;// used for TOP, makes for 50 hz PWM = (8,000,000 / (8 * 50)) - 1
&nbsp;&nbsp;&nbsp;&nbsp;ICR1 = 19999;

&nbsp;&nbsp;&nbsp;&nbsp;// servo pins outputs
&nbsp;&nbsp;&nbsp;&nbsp;DDRA = _BV(PA5) | _BV(PA6);

&nbsp;&nbsp;&nbsp;&nbsp;// set up counter 1 (16 bit) to act as a dual channel PWM generator
&nbsp;&nbsp;&nbsp;&nbsp;// comparator mode = non-inverting, use ICR1 as TOP and have a prescale of 8.
&nbsp;&nbsp;&nbsp;&nbsp;TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM11);
&nbsp;&nbsp;&nbsp;&nbsp;TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS11);
}

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
&nbsp;&nbsp;return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

int main() {

&nbsp;&nbsp;adcinit();
&nbsp;&nbsp;pwminit();
&nbsp;&nbsp;&nbsp;&nbsp;sei();

&nbsp;&nbsp;&nbsp;&nbsp;// START A2D
&nbsp;&nbsp;&nbsp;&nbsp;ADCSRA |= (1 &lt;&lt; ADSC);

&nbsp;&nbsp;while(1) {
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;//700 to 2400
&nbsp;&nbsp;&nbsp;&nbsp;//but here we need only 50 degress
&nbsp;&nbsp;&nbsp;&nbsp;OCR1A = map(ADC, 0, 1023, 700, 1100);
&nbsp;&nbsp;&nbsp;&nbsp;ADMUX |= (1 &lt;&lt; MUX1);
&nbsp;&nbsp;&nbsp;&nbsp;ADMUX &amp;= ~(1 &lt;&lt; MUX0);
&nbsp;&nbsp;&nbsp;&nbsp;Delay_ms(2);
&nbsp;&nbsp;&nbsp;&nbsp;OCR1B = map(ADC, 0, 1023, 700, 1100);
&nbsp;&nbsp;&nbsp;&nbsp;ADMUX |= (1 &lt;&lt; MUX0);
&nbsp;&nbsp;&nbsp;&nbsp;ADMUX &amp;= ~(1 &lt;&lt; MUX1);
&nbsp;&nbsp;&nbsp;&nbsp;Delay_ms(2);
&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;return(0);
}
</pre></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.workinprogress.ca/singing-birds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
