<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Hack a Day &#187; filter</title>
	<atom:link href="http://hackaday.com/tag/filter/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackaday.com</link>
	<description>Fresh hacks every day</description>
	<lastBuildDate>Fri, 10 Feb 2012 06:18:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hackaday.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/5560f98f805877b0e332f191cb9e0af3?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Hack a Day &#187; filter</title>
		<link>http://hackaday.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hackaday.com/osd.xml" title="Hack a Day" />
	<atom:link rel='hub' href='http://hackaday.com/?pushpress=hub'/>
		<item>
		<title>AVR chiptune project turns this simple code into music</title>
		<link>http://hackaday.com/2011/10/03/avr-chiptune-project-turns-this-simple-code-into-music/</link>
		<comments>http://hackaday.com/2011/10/03/avr-chiptune-project-turns-this-simple-code-into-music/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 19:25:34 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[musical hacks]]></category>
		<category><![CDATA[radio hacks]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[chiptune]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[ham]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=57491</guid>
		<description><![CDATA[[Mark] had seen a few examples of algorithmic music generation that takes some simple code and produces complex-sounding results. Apparently it&#8217;s possible to pipe the output of code like this directly to audio devices on a Linux box, but [Mark] decided to go a different direction. His project lets you play simple algorithms as audio using [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=57491&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-57492" title="c-code-for-chiptunes" src="http://hackadaycom.files.wordpress.com/2011/10/c-code-for-chiptunes.png" alt="" width="470" height="167" /></p>
<p>[Mark] had seen a few examples of algorithmic music generation that takes some simple code and produces complex-sounding results. Apparently it&#8217;s possible to pipe the output of code like this directly to audio devices on a Linux box, but [Mark] decided to go a different direction. His project lets you <a href="http://rfhead.net/?p=409">play simple algorithms as audio using AVR microcontrollers</a>.</p>
<p>Now the code work for this is very simple, but he hardware implementation is where things get interesting. Ostensibly, [Mark] didn&#8217;t have the components available to build a filter to use PWM as an audio signal. Being that he&#8217;s a ham operator, he grabbed some radio equipment he had on hand and whipped up an alternative. He&#8217;s feeding the PWM from an Arduino into the voltage controlled oscillator on a board meant for high-altitude balloon telemetry. The signal broadcast by this board is then picked up by his radio receiver, and played on some speakers.</p>
<p>Rube-Goldberg contraptions aside, the effect is pretty interesting, as you can hear in the latter half of the video clip which we&#8217;ve embedded after the jump.</p>
<p><span id="more-57491"></span><span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/10/03/avr-chiptune-project-turns-this-simple-code-into-music/"><img src="http://img.youtube.com/vi/jaTzSXN8uJU/2.jpg" alt="" /></a></span></p>
<br />Filed under: <a href='http://hackaday.com/category/musical-hacks/'>musical hacks</a>, <a href='http://hackaday.com/category/radio-hacks/'>radio hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/57491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/57491/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/57491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/57491/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/57491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/57491/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/57491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/57491/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/57491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/57491/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/57491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/57491/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/57491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/57491/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=57491&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/10/03/avr-chiptune-project-turns-this-simple-code-into-music/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/10/c-code-for-chiptunes.png" medium="image">
			<media:title type="html">c-code-for-chiptunes</media:title>
		</media:content>
	</item>
		<item>
		<title>Making your own lab instruments</title>
		<link>http://hackaday.com/2011/06/16/making-your-own-lab-instruments/</link>
		<comments>http://hackaday.com/2011/06/16/making-your-own-lab-instruments/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 23:01:51 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[chemistry hacks]]></category>
		<category><![CDATA[bike pump]]></category>
		<category><![CDATA[buchner flask]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[funnel]]></category>
		<category><![CDATA[pump]]></category>
		<category><![CDATA[vacuum]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=46212</guid>
		<description><![CDATA[[Andrey Mikhalchuk] is trying to gather a base set of lab instruments. Specifically, he&#8217;s looking for hardware that will let him quickly filter solids out of a liquid. He first started by adding a cotton disk to a plastic funnel. It does the job, but when left to gravity it&#8217;s quite slow. He needed a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=46212&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-46213" title="hacking-together-lab-supplies" src="http://hackadaycom.files.wordpress.com/2011/06/hacking-together-lab-supplies-e1308251426126.png" alt="" width="470" height="263" /></p>
<p>[Andrey Mikhalchuk] is trying to gather a base set of lab instruments. Specifically, he&#8217;s looking for <a href="http://www.rtfms.com/rtfms-6-superfast-filtration.htm">hardware that will let him quickly filter solids out of a liquid</a>. He first started by adding a cotton disk to a plastic funnel. It does the job, but when left to gravity it&#8217;s quite slow. He needed a way to speed up the flow even when the filter is heavily clogged with particulates.</p>
<p>There&#8217;s already a solution to this problem. It&#8217;s a glass container called a <a href="http://en.wikipedia.org/wiki/B%C3%BCchner_flask">Büchner Flask</a>. These feature a glass tube coming out from the neck. By hooking a vacuum pump up to this tube, reduced pressure inside the flask will pull the liquid through the filter in no time. Rather than purchase the specialty item, [Andrey] altered a rubber stopper to accept both the funnel, and a glass tube. This is a cheaper version because it uses a common conical flask but it works just as well. To create the vacuum, <a href="http://www.rtfms.com/rtfms-5-building-a-vacuum-pump.htm">an altered bike pump</a> was used. Check out videos of both hacks after the break.<span id="more-46212"></span><span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/06/16/making-your-own-lab-instruments/"><img src="http://img.youtube.com/vi/H3jjBv6968I/2.jpg" alt="" /></a></span></p>
<span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/06/16/making-your-own-lab-instruments/"><img src="http://img.youtube.com/vi/7lrAcJ67b78/2.jpg" alt="" /></a></span>
<br />Filed under: <a href='http://hackaday.com/category/chemistry-hacks/'>chemistry hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/46212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/46212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/46212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/46212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/46212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/46212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/46212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/46212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/46212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/46212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/46212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/46212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/46212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/46212/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=46212&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/06/16/making-your-own-lab-instruments/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/06/hacking-together-lab-supplies-e1308251426126.png" medium="image">
			<media:title type="html">hacking-together-lab-supplies</media:title>
		</media:content>
	</item>
		<item>
		<title>chipKIT Sketch: Mini Polyphonic Sampling Synth</title>
		<link>http://hackaday.com/2011/06/08/chipkit-sketch-mini-polyphonic-sampling-synth/</link>
		<comments>http://hackaday.com/2011/06/08/chipkit-sketch-mini-polyphonic-sampling-synth/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 15:01:48 +0000</pubDate>
		<dc:creator>Phil Burgess</dc:creator>
				<category><![CDATA[arduino hacks]]></category>
		<category><![CDATA[digital audio hacks]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[musical hacks]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[chipkit]]></category>
		<category><![CDATA[digital]]></category>
		<category><![CDATA[drums]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[Kraftwerk]]></category>
		<category><![CDATA[max32]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[pic32]]></category>
		<category><![CDATA[piezo]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[uno32]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=45011</guid>
		<description><![CDATA[In our hands-on review of the Digilent chipKIT Uno32, we posed the question of what the lasting appeal might be for a 32-bit Arduino work-alike. We felt it needed some novel applications exploiting its special features…not just the same old Arduino sketches with MOAR BITS. After the fractal demo, we’ve hit upon something unique and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=45011&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-45012" title="chipkit-synth-title" src="http://hackadaycom.files.wordpress.com/2011/06/chipkit-synth-title.jpg" alt="" width="470" height="330" /></p>
<p>In our <a href="http://hackaday.com/2011/05/27/chipkit-uno32-first-impressions-and-benchmarks/">hands-on review of the Digilent chipKIT Uno32</a>, we posed the question of what the lasting appeal might be for a 32-bit Arduino work-alike. We felt it needed some novel applications exploiting its special features…not just the same old Arduino sketches with MOAR BITS. After the fractal demo, we’ve hit upon something unique and fun…</p>
<p><span id="more-45011"></span></p>
<p>So just what are the chipKIT’s unique features over a stock Arduino? Until the expected Ethernet shield ships this summer, a few ideas are on hold. Let’s see then…there’s no shortage of MIPS, of course…but there’s also heaps of RAM and flash storage. And with the latter, sampled audio came to mind. There are Arduino shields for just this sort of thing — the <a href="http://hackaday.com/?s=%22wave+shield%22">Adafruit Wave Shield turns up in many projects</a>, using an SD card for sound storage — but if one’s needs are modest, the chipKIT’s PIC32 is perfectly capable of storing brief audio samples in its own flash program space, no cards, adapters or added expense required. We estimate the Max32 can hold nearly a full minute of voice-quality audio.</p>
<p>Playing with the idea, we found we could do one better. Actually, several better. A limitation of SD card-based players like the Wave Shield is that they can only play one sound at a time. Dealing with the FAT filesystem and buffering audio data off the card takes nearly everything the Arduino’s little ATmega chip can muster…polyphonic sound requires <a href="http://hackaday.com/2011/02/27/layering-pinball-audio-using-parallel-wav-shields/">kludges</a>. But our flash-resident audio samples on the chipKIT are trivial to access. With the fast 32-bit CPU, many samples can be processed simultaneously…and then, with gobs of RAM, time-based effects such as reverb can be added. And before we knew it, there was a toy synthesizer sitting on the table:</p>
<p><img class="alignnone size-full wp-image-45013" title="overview" src="http://hackadaycom.files.wordpress.com/2011/06/overview.jpg" alt="" width="470" height="450" /></p>
<p>Having previously dabbled with the PIC32 using Microchip’s tools, we were surprised by the simplicity with which this went together. A few early rough spots aside, the chipKIT and MPIDE environment show major promise for being every bit as simple as Arduino. In fact, the whole build was completed faster than the documentation phase. And then a second surprise, even to us: everything in the parts list, aside from the chipKIT board itself, is common stuff that could be found at <a href="http://hackaday.com/2011/05/27/speak-your-mind-and-help-radioshack-suck-less/">RadioShack</a>. No funky special ICs, components or mail-order shields. Most of the “magic” is in software, thanks to this fast microcontroller.</p>
<p>Here’s a demonstration of the finished mini-synth in action:</p>
<span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/06/08/chipkit-sketch-mini-polyphonic-sampling-synth/"><img src="http://img.youtube.com/vi/hdpQ8LEku90/2.jpg" alt="" /></a></span>
<p>Please excuse the demonstrator’s tragic lack of rhythm and coordination. This is why professional musicians get paid millions while amateurs lead sad lives as technology bloggers. Be thankful that we spared you the blooper reel.</p>
<p>Input is via five <a href="http://hackaday.com/2010/10/01/disco-drumming-with-piezo-sensitive-lighting/">piezoelectric</a> transducers (RadioShack #273-0073, $2.19 each) attached to analog inputs A0 through A4. We could have just used pushbuttons, sure, but we wanted something that could sense the pressure of each hit, and these were cheaper than force-sensitive resistors. Piezo sensors have a specific polarity, and the positive side (red wires) should connect to the analog inputs, and black to ground. There’s also a 2000 Ohm resistor added across each element:</p>
<p><img class="alignnone size-full wp-image-45014" title="schem-pads" src="http://hackadaycom.files.wordpress.com/2011/06/schem-pads.png" alt="" width="470" height="160" /></p>
<p>Input for the reverb effect is straightforward. Two 10K potentiometers on analog inputs A6 and A7 (these are on the second row of analog inputs on the chipKIT Uno32, not present on Arduino). One controls the amplitude, the other controls the delay:</p>
<p><img class="alignnone size-full wp-image-45015" title="schem-pots" src="http://hackadaycom.files.wordpress.com/2011/06/schem-pots.png" alt="" width="470" height="140" /></p>
<p>Finally, sound output uses high-speed PWM output on digital pin 3, passed through a simple low-pass filter to a headphone jack:</p>
<p><img class="alignnone size-full wp-image-45016" title="schem-filter" src="http://hackadaycom.files.wordpress.com/2011/06/schem-filter.png" alt="" width="470" height="150" /></p>
<p>On our breadboard we’re using a handy little <a href="http://www.sparkfun.com/products/10588">headphone breakout board</a> from SparkFun, but one could just solder the appropriate wire leads onto a bare jack from “The Shack” (ugh). You may want to optionally add a 1 Meg pot just before the headphone jack. The circuit worked fine as-is with headphones or an amplified iPod speaker, but totally saturated our camera’s microphone input when fed directly.</p>
<p>This demo uses 16 KHz sound samples. As per <a href="http://en.wikipedia.org/wiki/Nyquist_rate">Nyquist theory</a>, the low-pass filter is then designed for an 8 KHz (-ish) cutoff frequency. For purely voice applications, half those rates should be sufficient (saving flash space and allowing longer samples), and the two resistor values should then be doubled.</p>
<p>And that’s it for parts. Can you believe it? On to the code…</p>
<p>To begin, we need something that can convert sound files into a format the C compiler can use. An ugly little UNIX command-line utility converts WAV files from a very specific format (8-bit mono, uncompressed) into C header files that can be #included by the MPIDE project. Arduino normally would use the PROGMEM directive to put these tables into the code flash space, but that’s not required here. Surprisingly, the much-loved <a href="http://hackaday.com/2011/02/13/modern-freaking-pull-phone-numbers-from-youtube-audio/">Audacity</a> program wouldn&#8217;t export 8-bit WAVs, but we found it possible to batch convert sounds using iTunes.</p>
<p><pre class="brush: plain;">
const signed char sample_drum[] = {
        0x02,0x03,0x01,0x00,0x00,0x00,0x00,0x01,
        0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,
        ...HUNDREDS OF LINES OF STUFF...
        0xff,0xff,0xff,0xfd,0xfd,0xff,0x00,0x00,
        0x00,0x00,0x00,0x00,0x02,0x00 };
</pre></p>
<p>We’ll spare you the horror of looking at that code or doing the conversion. You can <a href="http://www.paintyourdragon.com/Synth.zip">download the complete set of project files here</a>, and then adapt it to your own needs. The remainder of this article deals only with the MPIDE code.</p>
<p>But first, one fix is required: in our <a href="http://hackaday.com/2011/05/27/chipkit-uno32-first-impressions-and-benchmarks/">prior article</a>, we encountered an issue with the chipKIT’s analog read speed, and a fix was discussed in the comments. This involves scrounging among the MPIDE source files for “wiring_analog.c” and changing a few lines. The old code resembles:</p>
<p><pre class="brush: plain;">
delayMicroseconds(99);
while ( ! mAD1GetIntFlag() ) { }
analogValue = ReadADC10(0);
mAD1ClearIntFlag();
</pre></p>
<p>This should be changed to:</p>
<p><pre class="brush: plain;">
delayMicroseconds(2);
mAD1ClearIntFlag();
while ( ! mAD1GetIntFlag() ) { }
analogValue = ReadADC10(0);
</pre></p>
<p>We’re told this change will be incorporated into later releases of the toolkit and this won’t be necessary for much longer. If you’re just ripping out the digital audio code from this project and ignoring this drum pad stuff, you can skip the change altogether.</p>
<p>And then there’s our sketch code:</p>
<p><pre class="brush: plain;">
// Mini sampling synthesizer for chipKIT Uno32.

#include &quot;sounds.h&quot;       // N_SAMPLES and data are here
#define PWM_PIN         3 // OC1 PWM output - don't change
#define SAMPLE_RATE 16000 // All samples fixed at 16 KHz
#define MAX_SOUNDS     10 // Polyphonic limit
#define MAX_ECHO     4000 // 1/4 sec fits in Uno32 RAM

short
  echo_data[MAX_ECHO]; // Circular buffer for echo

int
  echo_delay = 0, // Duration of echo effect
  echo_vol   = 0, // Echo effect volume (0-1023)
  echo_pos   = 0; // Current position in echo buffer
volatile int      // May change during interrupt:
  n_sounds   = 0; // Number of sounds currently playing

struct soundStruct {
  int sample; // Index of corresponding audio sample
  int pos;    // Current position within sample
  int vol;    // Playback volume, 0-1023
} sound[MAX_SOUNDS];

#define N_PADS N_SAMPLES // One pad for each sample

struct padStruct {
  short max;       // Max pressure during press (0-1023)
  short count;     // Timer for filtering out noise
  byte  triggered; // If set, currently reading a press
  short add;       // If &gt;0, begin sound at next interrupt
} pad[N_PADS];

void setup()
{
  memset(pad, 0, sizeof(pad));    // Clear drum pad data
  memset(echo_data, 0, sizeof(echo_data)); // Clear echo
  pinMode(PWM_PIN, OUTPUT);     // Enable PWM output pin

  // Open Timer2, 1:1 w/256 tick interval (for 8-bit PWM)
  OpenTimer2(T2_ON | T2_PS_1_1,256);
  OpenOC1(OC_ON | OC_TIMER2_SRC | OC_PWM_FAULT_PIN_DISABLE,
    0,0);

  // Open Timer1 with interrupt for sample mixer (16 KHz)
  ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_3);
  OpenTimer1(T1_ON | T1_PS_1_1, F_CPU / SAMPLE_RATE);

  delay(1);  // Slight delay avoids false trigger at start.
}

// Piezo transducers as input pads are fussy.
// To avoid false positives, a bit of hysteresis is used:
#define PRESS_MIN     20 // Must read at least this force
#define PRESS_COUNT    3 // for this many samples, then...
#define RELEASE_MAX    8 // Must read less than this force
#define RELEASE_COUNT 15 // for this many samples.
// Still imperfect; there are occasional double-triggerings
// and false triggers on adjacent pads.  Could be addressed
// with better mounting and isolation of pads and/or with
// improved input filtering in code or in hardware.

// The loop() function just reads pad and dial inputs; all
// audio work is done in the subsequent interrupt function.

void loop()
{
  int i, a;

  for(i = 0; i &lt; N_PADS; i++) {  // Sample each pad...
    a = analogRead(i);

    if(pad[i].triggered) {    // Previously pressed?
      if(a &lt;= RELEASE_MAX) {  // Yes, released now?
        if(++pad[i].count &gt;= RELEASE_COUNT) {  // Really?
          // Sounds aren't added to play list here, just
          // flagged; they're added to the mix in the
          // interrupt.  This avoids a race condition
          // where this code may be trying to add a sound
          // while the interrupt is removing one.
          pad[i].add       = pad[i].max;
          pad[i].triggered = 0;
          pad[i].count     = 0;
        }
      } else {  // Still pressed...watch for new max
        if(a &gt; pad[i].max) pad[i].max = a;
        pad[i].count = 0;  // Reset release counter
      }
    } else if(a &gt;= PRESS_MIN) {  // Untriggered; new press?
      if(++pad[i].count &gt;= PRESS_COUNT) {  // Really?
        pad[i].triggered = 1; // Flag to watch for release
        pad[i].count     = 0;
        pad[i].max       = a;
      }
    } else {  // Untriggered and below press threshold
      pad[i].count = 0;  // Clear press counter
    }
  }

  // Echo parameters come from potentiometers on A6 and A7
  echo_vol   = analogRead(6);
  echo_delay = map(analogRead(7), 0, 1023, 0, MAX_ECHO);
}

// This is the mixing/sample-playing interrupt,
// invoked at 16 KHz to match the audio sample rate.
// With guidance from Mark Sproul's PIC32 port of
// Brett Hagman's Tone library for Arduino.
extern &quot;C&quot;
{

void __ISR(_TIMER_1_VECTOR,ipl3) playSample(void)
{
  int i = 0, sum = 0;

  mT1ClearIntFlag();  // Clear interrupt flag

  while(i &lt; n_sounds) {  // For each sound playing...
    // Waveform is cumulative, NOT averaged
    sum += (int)sample[sound[i].sample].data[sound[i].pos] *
      sound[i].vol;
    sound[i].pos++;  // Advance counter.  If end hit...
    if(sound[i].pos &gt;= sample[sound[i].sample].size) {
      n_sounds--;  // Decrement number of sounds playing:
      // Move sound at end of list to the slot currently
      // occupied by the vacating sound (unless the same)
      if(i &lt; n_sounds) {
        memcpy(&amp;sound[i], &amp;sound[n_sounds],
          sizeof(soundStruct));
        continue;  // Sound moved; dont advance index
      }
    }
    i++;
  }
  sum /= 1024;

  // Add in echo effect (if enabled) from circular buffer.
  // This takes place before audio level clipping so that
  // any clipping distortion won't be repeated in echo.
  if((echo_delay &gt; 0) &amp;&amp; (echo_vol &gt; 0)) {
    sum += echo_data[echo_pos] * (echo_vol + 1) / 1024;
    echo_data[echo_pos] = sum;
    if(++echo_pos &gt;= echo_delay) echo_pos = 0;
  }

  // Clip audio to 8-bit range.  This may cause distortion
  // when multiple sounds or echo exceed the 8-bit range.
  // Invoking the &quot;quick &amp; dirty&quot; alibi again.
  if(sum &lt; -128)     sum = -128;
  else if(sum &gt; 127) sum =  127;

  SetDCOC1PWM(sum + 128);  // Set PWM output value 0-255

  // Check for any new sounds flagged by loop().
  // Done last because sounds finished above will
  // free up polyphonic slots.
  for(i = 0; i &lt; N_PADS; i++) {
    if(pad[i].add) {
      if(n_sounds &lt; MAX_SOUNDS) {
        sound[n_sounds].sample = i;
        sound[n_sounds].pos    = 0;
        sound[n_sounds].vol    = pad[i].add + 1;
        n_sounds++;
      }
      pad[i].add = 0;  // Clear flag even if not added
    }
  }
}

} // end extern &quot;C&quot;
</pre></p>
<h2>Explanation:</h2>
<p>The setup() function initializes two timers:</p>
<ul>
<li>Timer 2 and Output Compare 1 (hardware features of the PIC32 chip) are used for pulse width modulation (<a href="http://hackaday.com/2011/05/14/optimizing-code-for-pwm-efficiency/">PWM</a>). In conjunction with the filter previously described, this positions the speaker for each audio sample (Google for “PWM DAC” for explanations and examples). The PWM input clock is set to the chip’s full speed of 80 MHz, with an interval of 256 “ticks” (for 8-bit resolution), yielding a PWM waveform at 312,500 Hz. For this sort of DAC filtering it’s recommended that the PWM frequency be at least ten times the sample rate, so this is more than adequate for our needs. This is also why the code bypasses the native Arduino analogWrite() function for PWM, which operates on a much slower clock. Lastly, using Output Compare 1 dictates that we <em>must</em> use digital pin 3 for the audio output; this is one of the five native hardware PWM lines on this chip.</li>
<li>Timer 1 operates at our audio sample frequency (16 KHz) and has an <a href="http://hackaday.com/2010/09/27/beginner-concepts-all-about-avr-interrupts/">interrupt</a> function attached. This function mixes audio samples and changes the PWM duty cycle of Timer2/OC1. The rates on both of these timers are set up once and never need to change, just the one duty cycle is varied.</li>
</ul>
<p>This section of the code (and one line in the interrupt function) is admittedly not very Arduino-like, directly accessing hardware features in a non-portable manner. A more formal implementation would abstract these details into a library to which the novice programmer could just pass data. But for the sake of a simple, single-file demo, there it is, warts and all. In many ways, this is just a starting point to work from.</p>
<p>The loop() function reads the state of the piezo sensors and marks sounds to be played (received by the interrupt, later). There’s some crude <a href="http://hackaday.com/2010/11/09/debounce-code-one-post-to-rule-them-all/">debouncing</a> of the piezo inputs…this really could use some more sophisticated filtering (which the PIC32 could easily handle), but it was skipped for brevity. The code generally detects varying pressure, but there’s still a fair bit of false triggering going on. In this function the reverb controls are also read: just two analogRead() calls, with the second one then mapped to the full length of the reverb buffer.</p>
<p>The interrupt handler is where all the fun stuff happens, and it’s surprisingly simple.</p>
<p>The extern “C” declaration makes the C++ compiler happy with the interrupt function declaration.</p>
<p>The program is designed for up to ten concurrent sounds, the details of which are held in the “sound” structure array (there’s more than enough CPU performance for greater polyphony, but it’s mostly just a matter that the input pads aren’t terribly practical for this). When a pad hit is sensed, a new item is added to this array (up to the maximum). Structure elements indicate which audio sample is used for this sound, the current playback position within the sample, and the volume level.</p>
<p>Audio samples are stored as signed values (rather than unsigned) because this makes them easier to mix (just add together) and easier to adjust gains (just multiply). Every opportunity is taken to use fixed-point math. From the prior fractal demo, we saw what a massive performance difference this can make — sometimes orders of magnitude. Most of our analog readings (returned as 10 bit integers from 0 to 1023) correspond to a gain (relative volume) value of 0.0 to 1.0 (or 0% to 100%). To perform this scaling in fixed-point units, add 1 to the reading, perform the multiplication (one instruction on the PIC32), then divide by 1024 (a simple shift operation, also one instruction). There’s no loss in accuracy vs. converting to floating-point; the source and destination values are going to be quantized anyway.</p>
<p><pre class="brush: plain;">
// Floating-point, slow:
// scale = float 0.0 to 1.0
out = (int)((float)in * scale);

// Fixed-point, crazy fast:
// scale = integer 0 to 1023
out = in * (scale + 1) / 1024;
</pre></p>
<p>Along these lines, note that where the audio samples are summed, this division is skipped until the end. This saves some cycles and the result works out the same. Algebraically speaking, (A/X)+(B/X)=(A+B)/X, and so forth. The interim 32-bit sum isn’t likely to overflow.</p>
<p>Fixed-point math happens again when applying reverb. The echo volume, in the integer variable echo_vol (10 bit again, from one of the analog knobs) is in the range 0 to 1023, corresponding to 0% (no reverb) to 100% (echo is as loud as the original sound). Reverb (in echo_data[] array) is a circular buffer — as sounds are played, the contents here (scaled by echo_vol) are first added to the output, then the result is placed back in the same position in the array and the position counter is incremented by one. When the end of the array is reached (or a shorter limit indicated by echo_delay) we “wrap around” back to the beginning.</p>
<p>The final resulting audio value is clipped to an 8-bit range. This may introduce clipping distortion when many loud sounds are used simultaneously. For brevity again, bells and whistles have been omitted, but courageous programmers could opt to add “soft clipping” here to limit such distortion. There’s ample CPU muscle.</p>
<p>The final 8-bit signed value is then transposed into the unsigned range and fed into the OC1 duty cycle for PWM output.</p>
<p>Lastly, the interrupt checks for any sounds that the loop() function flagged as being “hit,” and adds these to the concurrent play list. This flag-and-add behavior, rather than adding items directly in loop(), avoids a potentially nasty race condition whereby loop() could be in the midst of adding a sound just as the interrupt is removing others, throwing off the counter.</p>
<p>And that’s all there is to it. This demo only uses about one fourth of the storage on the Uno32, which itself has one fourth the capacity of the Max32…and we’ve yet to exploit any sort of <a href="http://hackaday.com/2010/09/23/codec2-gnu-low-bitrate-speech-codec/">compression</a>. There could be some fun applications here, maybe adding <a href="http://hackaday.com/2011/06/06/retro-video-games-sounds-for-your-toilet/">better Super Mario sounds to toilets</a> or voice prompts to other chipKIT projects (“Your door is ajar”). What other ideas could you see happening here?</p>
<br />Filed under: <a href='http://hackaday.com/category/arduino-hacks/'>arduino hacks</a>, <a href='http://hackaday.com/category/digital-audio-hacks/'>digital audio hacks</a>, <a href='http://hackaday.com/category/how-to/'>how-to</a>, <a href='http://hackaday.com/category/microcontrollers/'>Microcontrollers</a>, <a href='http://hackaday.com/category/musical-hacks/'>musical hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/45011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/45011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/45011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/45011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/45011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/45011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/45011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/45011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/45011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/45011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/45011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/45011/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/45011/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/45011/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=45011&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/06/08/chipkit-sketch-mini-polyphonic-sampling-synth/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">philburgess</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/06/chipkit-synth-title.jpg" medium="image">
			<media:title type="html">chipkit-synth-title</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/06/overview.jpg" medium="image">
			<media:title type="html">overview</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/06/schem-pads.png" medium="image">
			<media:title type="html">schem-pads</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/06/schem-pots.png" medium="image">
			<media:title type="html">schem-pots</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/06/schem-filter.png" medium="image">
			<media:title type="html">schem-filter</media:title>
		</media:content>
	</item>
		<item>
		<title>Junkyard fish tank</title>
		<link>http://hackaday.com/2011/02/16/junkyard-fish-tank/</link>
		<comments>http://hackaday.com/2011/02/16/junkyard-fish-tank/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 19:30:52 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[home hacks]]></category>
		<category><![CDATA[aquarium]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[plastic bottle]]></category>
		<category><![CDATA[polystyrene]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=35148</guid>
		<description><![CDATA[So your house looks like a dumping ground for useless junk? Yeah, we know it&#8217;s the hacker&#8217;s curse&#8230; you just can&#8217;t stop salvaging stuff. But follow [Pontazy69's] lead by building something useful out of that junk. He took an old polystyrene box and made it into this fishtank. You can see that the sides and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=35148&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-35149" title="polystyrene-fish-tank" src="http://hackadaycom.files.wordpress.com/2011/02/polystyrene-fish-tank.jpg" alt="" width="470" height="319" /></p>
<p>So your house looks like a dumping ground for useless junk? Yeah, we know it&#8217;s the hacker&#8217;s curse&#8230; you just can&#8217;t stop salvaging stuff. But follow [Pontazy69's] lead by building something useful out of that junk. He took an old polystyrene box and <a href="http://www.youtube.com/watch?v=ac3SVHpuPhw">made it into this fishtank</a>. You can see that the sides and back of the box has gone unaltered, but the front wall is missing. [Pontazy69] marked and cut straight lines while leaving a lip around the edge. Silicone was used to glue some acrylic (or perhaps glass?) to the inside of this lip. Once dried he added another bead around the outside to ensure it doesn&#8217;t leak. Few fish would be happy here without some type of filter so he built one of those out of an old plastic bottle and some other pieces. See videos that show you how to build both the tank and the filter after the break.</p>
<p>We love aquarium hacks almost as much as clock hacks. So check out the <a href="http://hackaday.com/2011/01/17/aquarium-water-exchanger/">water exchange system</a>, and a couple of <a href="http://hackaday.com/2010/02/26/cooling-leds-by-heating-the-water-saves-on-electricity/">different</a> lighting <a href="http://hackaday.com/2010/01/29/salty-leds/">systems</a>. Then document your own aquarium projects and <a href="http://hackaday.com/contact-hack-a-day/">let us know about them</a>.</p>
<p><span id="more-35148"></span></p>
<p>Fish tank made from polystyrene</p>
<span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/02/16/junkyard-fish-tank/"><img src="http://img.youtube.com/vi/ac3SVHpuPhw/2.jpg" alt="" /></a></span>
<p>Plastic bottle fish tank filter</p>
<span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/02/16/junkyard-fish-tank/"><img src="http://img.youtube.com/vi/9h02dIBLVQ8/2.jpg" alt="" /></a></span>
<p>[Thanks Greg]</p>
<br />Filed under: <a href='http://hackaday.com/category/home-hacks/'>home hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/35148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/35148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/35148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/35148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/35148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/35148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/35148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/35148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/35148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/35148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/35148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/35148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/35148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/35148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=35148&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/02/16/junkyard-fish-tank/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/02/polystyrene-fish-tank.jpg" medium="image">
			<media:title type="html">polystyrene-fish-tank</media:title>
		</media:content>
	</item>
		<item>
		<title>Turning music into a light show</title>
		<link>http://hackaday.com/2011/01/22/turning-music-into-a-light-show/</link>
		<comments>http://hackaday.com/2011/01/22/turning-music-into-a-light-show/#comments</comments>
		<pubDate>Sat, 22 Jan 2011 19:19:10 +0000</pubDate>
		<dc:creator>Chris Nelson</dc:creator>
				<category><![CDATA[arduino hacks]]></category>
		<category><![CDATA[digital audio hacks]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[op-amp]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=33275</guid>
		<description><![CDATA[[nickinoki] Made a light show using some amplifiers and an arduino. First he created a microphone circuit based around a LM386 Audio Amplifier. After amplifying the output of the microphone a second time, he uses three bandpass filters to block all but a few desired frequencies from reaching the arduino.  By only letting a few frequencies through the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=33275&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-large wp-image-33277" title="Sound-into-Light-shows" src="http://hackadaycom.files.wordpress.com/2011/01/sound-into-light-shows1.jpg?w=450&#038;h=337" alt="" width="450" height="337" /></p>
<p>[nickinoki] Made a <a href="http://www.instructables.com/id/Sound-into-Light-shows/#step1">light show</a> using some amplifiers and an arduino. First he created a microphone circuit based around a LM386 Audio Amplifier. After amplifying the output of the microphone a second time, he uses three bandpass filters to block all but a few desired frequencies from reaching the arduino.  By only letting a few frequencies through the arduino is able to determine if the song is louder at higher or lower frequencies.  Then using the three analogue inputs he created a scheme for generating the light show on an arduino. While he was unable to achieve the exact target frequencies with his bandpass filters they worked well enough to allow him to successfully generate the light show.</p>
<br />Filed under: <a href='http://hackaday.com/category/arduino-hacks/'>arduino hacks</a>, <a href='http://hackaday.com/category/digital-audio-hacks/'>digital audio hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/33275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/33275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/33275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/33275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/33275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/33275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/33275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/33275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/33275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/33275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/33275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/33275/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/33275/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/33275/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=33275&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/01/22/turning-music-into-a-light-show/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">christopernelson</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/01/sound-into-light-shows1.jpg?w=450" medium="image">
			<media:title type="html">Sound-into-Light-shows</media:title>
		</media:content>
	</item>
		<item>
		<title>Quiet Dust Extractor from Scavenged Materials</title>
		<link>http://hackaday.com/2011/01/05/quiet-dust-extractor-from-scavenged-materials/</link>
		<comments>http://hackaday.com/2011/01/05/quiet-dust-extractor-from-scavenged-materials/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 22:30:21 +0000</pubDate>
		<dc:creator>Joseph Thibodeau</dc:creator>
				<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[Cyclone]]></category>
		<category><![CDATA[dust]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[noise]]></category>
		<category><![CDATA[protection]]></category>
		<category><![CDATA[safety]]></category>
		<category><![CDATA[soundproofing]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=32522</guid>
		<description><![CDATA[As with many of the projects covered on hackaday, [bongodrummer]&#8216;s Dust Sniper came about because of a lack of effective commercial solutions, in this case to the problem of quiet dust extraction. Workshops are generally full of dust and noise, both of which take their toll on the human body. This is why safety regulations [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=32522&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-32526" title="In-Use-Evaluation-Maintenance" src="http://hackadaycom.files.wordpress.com/2011/01/in-use-evaluation-maintenance.jpg" alt="" width="470" height="346" /></p>
<p>As with many of the projects covered on hackaday, [bongodrummer]&#8216;s <a href="http://www.instructables.com/id/Dust-Sniper-quiet-extractor-system/">Dust Sniper</a> came about because of a lack of effective commercial solutions, in this case to the problem of quiet dust extraction.</p>
<p>Workshops are generally full of dust and noise, both of which take their toll on the human body. This is why safety regulations exist for noisy and dusty workplaces and&#8211;as [bongodrummer] rightly points out&#8211;we have to take precautions in our own home and community workshops. Hearing protectors, dust masks and safety goggles are integral, but reducing the amount of dust and noise in the fist place is paramount.</p>
<p>Using mostly scavenged materials [bongodrummer] did a quality job building the Dust Sniper&#8211;and all for a bill of materials totaling £20. It has an integrated work surface, automatic switches on 2 vacuum lines to sync up with power tools, a cyclonic air filter that prevents clogging the HEPA filter and reducing suction power, inlet and outlet soundproofing, and a plain old power outlet for good measure.</p>
<p>Whether or not you&#8217;re interested in building an integrated workbench/extractor system like this one, we recommend you check out the details of the cyclone filter and the sound reducing components. Not only are they an interesting read, but they could be useful to apply in other projects, for example a <a href="http://hackaday.com/2008/08/05/how-to-the-hackers-soldering-station/">soldering station with fume hood</a>.</p>
<p>We think it would be really neat to include more cyclones in our projects. Stick around after the break to see [bongodrummer]&#8216;s prototype cyclone filter in action.</p>
<p><span id="more-32522"></span><span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/01/05/quiet-dust-extractor-from-scavenged-materials/"><img src="http://img.youtube.com/vi/o850ATauMDM/2.jpg" alt="" /></a></span></p>
<br />Filed under: <a href='http://hackaday.com/category/tool-hacks/'>tool hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/32522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/32522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/32522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/32522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/32522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/32522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/32522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/32522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/32522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/32522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/32522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/32522/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/32522/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/32522/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=32522&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/01/05/quiet-dust-extractor-from-scavenged-materials/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josephthibodeau</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/01/in-use-evaluation-maintenance.jpg" medium="image">
			<media:title type="html">In-Use-Evaluation-Maintenance</media:title>
		</media:content>
	</item>
		<item>
		<title>Anaglyphic photography made easy</title>
		<link>http://hackaday.com/2010/11/22/anaglyphic-photography-made-easy/</link>
		<comments>http://hackaday.com/2010/11/22/anaglyphic-photography-made-easy/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 21:00:33 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[digital cameras hacks]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[anaglyph]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[gimp]]></category>
		<category><![CDATA[stereoscopic]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=31008</guid>
		<description><![CDATA[[ProfHankD] came up with a pretty easy way to take 3D photos using a single lens. He&#8217;s making Anaglyph images which use color filtering glasses to produce stereoscopic 3D effects. We&#8217;ve seen stereoscopic imaging hacks that use two cameras or a clever combination of mirrors, but this one uses a special filter and post-processing. [ProfHankD] [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=31008&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-31010" title="anaglyphic-photography" src="http://hackadaycom.files.wordpress.com/2010/11/anaglyphic-photography-e1290451996399.jpg" alt="" width="470" height="313" /></p>
<p>[ProfHankD] came up with a pretty easy way to <a href="http://www.instructables.com/id/Use-Your-Camera-To-Capture-3D-Anaglyphs">take 3D photos using a single lens</a>. He&#8217;s making <a href="http://en.wikipedia.org/wiki/Anaglyph_image">Anaglyph images</a> which use color filtering glasses to produce stereoscopic 3D effects. We&#8217;ve seen stereoscopic imaging hacks that <a href="http://hackaday.com/2010/01/14/spherical-and-stereoscopic-photography/">use two cameras</a> or a clever <a href="http://hackaday.com/2010/09/08/steroscopic-rig-requires-only-one-camera/">combination of mirrors</a>, but this one uses a special filter and post-processing. [ProfHankD] drew up a template that can be used to properly align two colored filters, like those in the lens cap seen above. Once installed, just snap all the pictures you want and then hit them with your favorite photo editing software. This involves separating the color channels of the photograph and offsetting them to increase the depth of focus.</p>
<p>It&#8217;s a nice little process, and his writeup is easy to understand even if you&#8217;re not a hardcore photography guru.</p>
<p>[Thanks Paul]</p>
<br />Filed under: <a href='http://hackaday.com/category/digital-cameras-hacks/'>digital cameras hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/31008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/31008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/31008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/31008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/31008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/31008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/31008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/31008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/31008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/31008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/31008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/31008/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/31008/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/31008/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=31008&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2010/11/22/anaglyphic-photography-made-easy/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2010/11/anaglyphic-photography-e1290451996399.jpg" medium="image">
			<media:title type="html">anaglyphic-photography</media:title>
		</media:content>
	</item>
		<item>
		<title>Make a point-and-shoot see infrared light</title>
		<link>http://hackaday.com/2010/11/17/make-a-point-and-shoot-see-infrared-light/</link>
		<comments>http://hackaday.com/2010/11/17/make-a-point-and-shoot-see-infrared-light/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 18:30:43 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[digital cameras hacks]]></category>
		<category><![CDATA[canon]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[ir]]></category>
		<category><![CDATA[Kinect]]></category>
		<category><![CDATA[night vision]]></category>
		<category><![CDATA[powershot]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=30835</guid>
		<description><![CDATA[[Daniel Reetz] has caught the Kinect hacking fever. But he needs one important tool for his work; a camera that can see infrared light. This shouldn&#8217;t be hard to accomplish, as the sensors in digital cameras are more than capable of this task, but it requires the removal of an infrared filter. In [Daniel's] case [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=30835&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-30836" title="removing-camera-ir-filter" src="http://hackadaycom.files.wordpress.com/2010/11/removing-camera-ir-filter.jpg" alt="" width="470" height="294" /></p>
<p>[Daniel Reetz] has caught the Kinect hacking fever. But he needs one important tool for his work; a camera that can see infrared light. This shouldn&#8217;t be hard to accomplish, as the sensors in digital cameras are more than capable of this task, but it requires the removal of an infrared filter. In [Daniel's] case he <a href="http://www.futurepicture.org/?p=97">disassembled a Canon Powershot</a> to get at that filter. There&#8217;s a lot packed into those point-and-shoot camera bodies and his teardown images tell that tale. He also ended up with extra parts after putting it back together but that didn&#8217;t seem to do any harm.</p>
<p>After the break you can see video that shows the Kinect&#8217;s speckled IR grid, which is why he needed IR sensing in the first place. But there&#8217;s also some interesting photos at the bottom of his post showing the effect achieved in outdoor photography by removing the filter.</p>
<p>The flash never made it back in the camera. That&#8217;d be a perfect place for an IR light source. You&#8217;d end up with <a href="http://hackaday.com/2010/10/02/diy-night-vision-monocle/">a night-vision camera</a> that way.</p>
<p><span id="more-30835"></span><span style="text-align:center; display: block;"><a href="http://hackaday.com/2010/11/17/make-a-point-and-shoot-see-infrared-light/"><img src="http://img.youtube.com/vi/28JwgxbQx8w/2.jpg" alt="" /></a></span></p>
<br />Filed under: <a href='http://hackaday.com/category/digital-cameras-hacks/'>digital cameras hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/30835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/30835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/30835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/30835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/30835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/30835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/30835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/30835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/30835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/30835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/30835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/30835/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/30835/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/30835/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=30835&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2010/11/17/make-a-point-and-shoot-see-infrared-light/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2010/11/removing-camera-ir-filter.jpg" medium="image">
			<media:title type="html">removing-camera-ir-filter</media:title>
		</media:content>
	</item>
		<item>
		<title>Open Call: send us your Debounce code</title>
		<link>http://hackaday.com/2010/10/13/open-call-send-us-your-debounce-code/</link>
		<comments>http://hackaday.com/2010/10/13/open-call-send-us-your-debounce-code/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 20:11:32 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[HackIt]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[debounce]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=29271</guid>
		<description><![CDATA[If you&#8217;ve ever designed an embedded system with at least one button you&#8217;ve had to deal with button debouncing. This is also know as contact bounce, a phenomenon where a button press can be registered as multiple button presses if not handled correctly. One way to take care of this is with a hardware filter built from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=29271&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-29272" title="debounce-waveform" src="http://hackadaycom.files.wordpress.com/2010/10/debounce-waveform.jpg" alt="" width="470" height="244" /></p>
<p>If you&#8217;ve ever designed an embedded system with at least one button you&#8217;ve had to deal with button debouncing. This is also know as <a href="http://en.wikipedia.org/wiki/Debounce#Contact_bounce">contact bounce</a>, a phenomenon where a button press can be registered as multiple button presses if not handled correctly. One way to take care of this is with a hardware filter built from a resistor-capacitor setup, or by using a couple of NAND gates. We find that [Jack Ganssle] put together the most comprehensive and <a href="http://www.ganssle.com/debouncing.htm">approachable look at contact bounce</a> which you should read through if you want to learn more.</p>
<p>We&#8217;re interested in software solutions for debouncing buttons. This seems to be <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=33821">one of the most common forum questions</a> but it can be hard to find answers in the form of reliable code examples. Do you have debounce code that you depend on in every application? Are you willing to share it with the world? We&#8217;d like to gather as many examples as possible and publish them in one-post-to-rule-them-all.</p>
<h2>Send your debounce code to: <a href="mailto:debounce@hackaday.com">debounce@hackaday.com</a></h2>
<p>Here&#8217;s some guidelines to follow:</p>
<ul>
<li><strong>Please only include debounce code.</strong> Get rid of other unrelated functions/etc.</li>
<li><strong>You should send C code.</strong> If you want to also send an assembly code version that&#8217;s fine, but it must be supplementary to the C code.</li>
<li><strong>Please comment your code.</strong> This will help others understand and use it. You may be tempted to explain the code in your email but this info is best placed in the code comments</li>
<li><strong>Cite your sources.</strong> If you adapted this code from someone else&#8217;s please include a note about that in the code comments.</li>
</ul>
<p>As an example we&#8217;ve included one of our favorite sets of debounce code after the break. Please note how it follows the guidelines listed above.</p>
<p><span id="more-29271"></span></p>
<p><pre class="brush: cpp; wrap-lines: false;">/*--------------------------------------------------------------------------
10/13/2010: Button debounce code by Mike Szczys

based on &quot;danni debounce&quot; code by Peter Dannegger:
http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;p=189356#189356

This code detects and debounces button presses. It is tailored for use with
AVR microcontrollers but I've adapted it for other architectures easily and
successfully. It can be modified to use all eight bits on the same port
for up to eight buttons.

The interrupt service routine (ISR) at the bottom uses binary counter
variables (ct0 and ct1) to check the buttons once every 10ms until 40ms has
passed. If the button registeres the first and last times it reads it as
a keypress. There is no functionality in this code for detecting a held
button.
--------------------------------------------------------------------------*/

// F_CPU used by debounce to calculate 10ms interrupts
#define F_CPU 1200000

#include &lt;avr/io.h&gt;
#include &lt;avr/interrupt.h&gt;

//define pins used by buttons
#define KEY_DDR		DDRB
#define KEY_PORT	PORTB
#define KEY_PIN		PINB
#define KEY0		1	//Button on PB1
#define KEY1		2	//Button on PB2

//Debounce variables
unsigned char debounce_cnt = 0;
volatile unsigned char key_press;
unsigned char key_state;

/*--------------------------------------------------------------------------
  Prototypes
--------------------------------------------------------------------------*/
unsigned char get_key_press( unsigned char key_mask );
void init_timers(void);
void init_io(void);

/*--------------------------------------------------------------------------
  FUNC: 10/13/10 - Used to read debounced button presses
  PARAMS: A keymask corresponding to the pin for the button you with to poll
  RETURNS: A keymask where any high bits represent a button press
--------------------------------------------------------------------------*/
unsigned char get_key_press( unsigned char key_mask )
{
  cli();			// read and clear atomic !
  key_mask &amp;= key_press;	// read key(s)
  key_press ^= key_mask;	// clear key(s)
  sei();			// enable interrupts
  return key_mask;
}

/*--------------------------------------------------------------------------
  FUNC: 10/13/10 - Sets and starts a system timer
  PARAMS: NONE
  RETURNS: NONE
--------------------------------------------------------------------------*/
void init_timers(void)
{
  cli();			// read and clear atomic !
  //Timer0 for buttons
  TCCR0B |= 1&lt;&lt;CS02 | 1&lt;&lt;CS00;	//Divide by 1024
  TIMSK0 |= 1&lt;&lt;TOIE0;		//enable timer overflow interrupt
  sei();			// enable interrupts
}

/*--------------------------------------------------------------------------
  FUNC: 10/13/10 - Initialize input and output registers
  PARAMS: NONE
  RETURNS: NONE
--------------------------------------------------------------------------*/
void init_io(void)
{
  //Setup Buttons
  KEY_DDR &amp;= ~((1&lt;&lt;KEY0) | (1&lt;&lt;KEY1));	//Set pins as input
  KEY_PORT |= (1&lt;&lt;KEY0) | (1&lt;&lt;KEY1);	//enable pull-up resistors
}

/*--------------------------------------------------------------------------
  FUNC: 10/13/10 - Main
--------------------------------------------------------------------------*/
int main(void)
{
  init_timers();	//start the timer
  init_io();		//setup the buttons

  for (;;) //loop forever
  {
    if( get_key_press( 1&lt;&lt;KEY0 ))
    {
      //KEY0 press detected. Do something here
    }

    if (get_key_press( 1&lt;&lt;KEY1 ))
    {
      //KEY1 press detected. Do something here
    }
  }
}

//--------------------------------------------------------------------------
ISR(TIM0_OVF_vect)           // interrupt every 10ms
{
  static unsigned char ct0, ct1;
  unsigned char i;

  //TCNT0 is where TIMER0 starts counting. This calculates a value based on
  //the system clock speed that will cause the timer to reach an overflow
  //after exactly 10ms
  TCNT0 = (unsigned char)(signed short)-(((F_CPU / 1024) * .01) + 0.5);   // preload for 10ms interrupts

  i = key_state ^ ~KEY_PIN;    // key changed ?
  ct0 = ~( ct0 &amp; i );          // reset or count ct0
  ct1 = ct0 ^ (ct1 &amp; i);       // reset or count ct1
  i &amp;= ct0 &amp; ct1;              // count until roll over ?
  key_state ^= i;              // then toggle debounced state
  key_press |= key_state &amp; i;  // 0-&gt;1: key press detect
}</pre></p>
<p>[Photo credit: <a href="http://www.ganssle.com/debouncing.htm">Jack Ganssle</a>]</p>
<br />Filed under: <a href='http://hackaday.com/category/hackit/'>HackIt</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/29271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/29271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/29271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/29271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/29271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/29271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/29271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/29271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/29271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/29271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/29271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/29271/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/29271/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/29271/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=29271&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2010/10/13/open-call-send-us-your-debounce-code/feed/</wfw:commentRss>
		<slash:comments>75</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2010/10/debounce-waveform.jpg" medium="image">
			<media:title type="html">debounce-waveform</media:title>
		</media:content>
	</item>
		<item>
		<title>Guitar effect shield for Maple</title>
		<link>http://hackaday.com/2010/07/25/guitar-effect-shield-for-maple/</link>
		<comments>http://hackaday.com/2010/07/25/guitar-effect-shield-for-maple/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 17:00:47 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[digital audio hacks]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[guitar]]></category>
		<category><![CDATA[maple]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=26447</guid>
		<description><![CDATA[[Okie] designed this audio effect shield for Maple. You&#8217;ll remember that Maple is a prototyping system built around an ARM processor, so there&#8217;s plenty of power and speed under the hood. First and foremost, the shield provides input and output filters to keep noise out of the system. From there a set of potentiometers let [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=26447&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-26448" title="maple-guitar-shield" src="http://hackadaycom.files.wordpress.com/2010/07/maple-guitar-shield.jpg" alt="" width="470" height="329" /></p>
<p>[Okie] designed this <a href="http://leaflabs.com/2010/07/audio-and-guitar-effects-on-maple/">audio effect shield for Maple</a>. You&#8217;ll remember that <a href="http://hackaday.com/2009/08/22/maple-beats-up-arduino-takes-its-shields/">Maple is a prototyping system</a> built around an ARM processor, so there&#8217;s plenty of power and speed under the hood. First and foremost, the shield provides input and output filters to keep noise out of the system. From there a set of potentiometers let you change the effect, with the manipulation like echo, distortion, and ring modulation happening in the firmware.</p>
<br />Filed under: <a href='http://hackaday.com/category/digital-audio-hacks/'>digital audio hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/26447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/26447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/26447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/26447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/26447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/26447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/26447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/26447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/26447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/26447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/26447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/26447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/26447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/26447/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=26447&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2010/07/25/guitar-effect-shield-for-maple/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2010/07/maple-guitar-shield.jpg" medium="image">
			<media:title type="html">maple-guitar-shield</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding an automotive cold air intake</title>
		<link>http://hackaday.com/2010/03/16/adding-an-automotive-cold-air-intake/</link>
		<comments>http://hackaday.com/2010/03/16/adding-an-automotive-cold-air-intake/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 22:06:24 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[transportation hacks]]></category>
		<category><![CDATA[air intake]]></category>
		<category><![CDATA[cavalier]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[PVC]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=22431</guid>
		<description><![CDATA[[Thomas] and a buddy were sucking down a few brews when they decided to hack their 2001 Chevy Cavalier for a bit better performance. If they could find a way to bring cooler air to the engine they speculated that they&#8217;d see an increase in efficiency. Instead of routing the air intake to a hood [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=22431&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-22432" title="automotive-cold-air-intake" src="http://hackadaycom.files.wordpress.com/2010/03/automotive-cold-air-intake.jpg" alt="" width="470" height="353" /></p>
<p>[Thomas] and a buddy were sucking down a few brews when they decided to <a href="http://s181.photobucket.com/albums/x136/ymmotfour/Cold%20air%20intake%20hack/">hack their 2001 Chevy Cavalier for a bit better performance</a>. If they could find a way to bring cooler air to the engine they speculated that they&#8217;d see an increase in efficiency. Instead of routing the air intake to a hood scoop, they took off the factory air filter and mounted a cold air filter in its place. PVC pipes were then used to create a delivery path from the front of the vehicle with the output in close proximity to the new filter. They tested their work and discovered a drop in intake temperature from 101 to 48 degrees Fahrenheit at 60 mph, and from 109 to 54 degrees Fahrenheit at 45 mph. Now the sedan runs better and generates more horsepower, all for around $35 in parts.</p>
<br />Filed under: <a href='http://hackaday.com/category/transportation-hacks/'>transportation hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/22431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/22431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/22431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/22431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/22431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/22431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/22431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/22431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/22431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/22431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/22431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/22431/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/22431/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/22431/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=22431&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2010/03/16/adding-an-automotive-cold-air-intake/feed/</wfw:commentRss>
		<slash:comments>116</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2010/03/automotive-cold-air-intake.jpg" medium="image">
			<media:title type="html">automotive-cold-air-intake</media:title>
		</media:content>
	</item>
		<item>
		<title>Infinite water</title>
		<link>http://hackaday.com/2008/07/04/infinite-water/</link>
		<comments>http://hackaday.com/2008/07/04/infinite-water/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 01:11:00 +0000</pubDate>
		<dc:creator>Juan Aguilar</dc:creator>
				<category><![CDATA[misc hacks]]></category>
		<category><![CDATA[dehydration]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[petcare]]></category>
		<category><![CDATA[pets]]></category>
		<category><![CDATA[solenoid]]></category>
		<category><![CDATA[tupperware]]></category>
		<category><![CDATA[water]]></category>

		<guid isPermaLink="false">http://hackaday.iheartcashews.com:8181/2008/07/04/infinite-water/</guid>
		<description><![CDATA[It&#8217;s Independence Day, so if you have pets and planned a trip, chances are you wrangled a pet sitter to keep your pet from starving or dehydrating to death. Next time, consider letting this infinite water dispenser help you instead. The dispenser is made of a Tupperware tub, a fish tank water filter, a float [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=2192&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img width="450" vspace="4" hspace="4" height="243" border="0" alt="" src="http://hackadaycom.files.wordpress.com/2008/07/had-infinite-water.jpg?w=450&#038;h=243" /><br />It&#8217;s Independence Day, so if you have pets and planned a trip, chances are you wrangled a pet sitter to keep your pet from starving or dehydrating to death. Next time, consider letting this <a href="http://www.jenrathbun.com/Electronics/InfiniteWater.html">infinite water dispenser</a> help you instead. </p>
<p>The dispenser is made of a Tupperware tub, a fish tank water filter, a float switch, and a water solenoid valve. It works essentially the same way as any toilet: the solenoid valve lets water into the filter where it is dispensed to the Tupperware container. The float switch is activated when the water in the container reaches a certain level. When the water level drops due to evaporation or thirsty pets, the float switch goes down and triggers the solenoid to let in more water. The whole works are powered by a GFI outlet for safety since this project involved water, electricity and pets.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/hackadaycom.wordpress.com/2192/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/hackadaycom.wordpress.com/2192/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/2192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/2192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/2192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/2192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/2192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/2192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/2192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/2192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=2192&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/07/04/infinite-water/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">juanaguilar</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/07/had-infinite-water.jpg" medium="image" />
	</item>
	</channel>
</rss>
