<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Final Crickets Code</title>
	<atom:link href="http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/</link>
	<description>A tale of romance between a boy and his LED's</description>
	<pubDate>Thu, 28 Aug 2008 18:52:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: mike.</title>
		<link>http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/#comment-18905</link>
		<dc:creator>mike.</dc:creator>
		<pubDate>Wed, 06 Aug 2008 17:11:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/#comment-18905</guid>
		<description>Finally modified!

/*
Concrete Crickets Arduino Code
 Michael J. Dory
 www.doryexmachina.com
 Written 04.11.07, revised 11.02.07 
 (thanks to code from Tom Igoe, Clay Shirky and Rob Faludi)
 */

int RangePotPin = 5;    // Analog input pin that the rangefinder is attached to
int RangePotValue = 0;   // value read from the pot

int MP3Pin = 12;    // the pin that the relay controlling the MP3 is attached to 

int blinkyPin = 13; // the pin that the reference LED is attached to

int onOffPin = 11; //the pin that the speaker attach/kill switch relay is on.

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 

  // set pins for output
  pinMode(blinkyPin, OUTPUT);
  pinMode(onOffPin, OUTPUT);
  pinMode(MP3Pin, OUTPUT);

  // initialize both pins at low
  digitalWrite(MP3Pin, LOW);
  digitalWrite(blinkyPin, LOW);

  delay(100);

  // turn MP3 Player on, blink pin 13 for reference
  digitalWrite(MP3Pin, HIGH);
  digitalWrite(blinkyPin, HIGH);
  delay(5000);

  // take both pins low again 
  digitalWrite(MP3Pin, LOW);
  digitalWrite(blinkyPin, LOW);

  delay(100);

  // blink LED three times quickly to show mp3 player is on
  blinky();

  // start playing the MP3
  delay (2000);
  digitalWrite(MP3Pin, HIGH);
  digitalWrite(blinkyPin, HIGH);
  delay(500);
  digitalWrite(MP3Pin, LOW);
  digitalWrite(blinkyPin, LOW);

  // blink three times to show that the MP3 player is playing and setup is complete
  blinky();

  // end setup
}


void loop() {
  RangePotValue = analogRead(RangePotPin);   // read the pot value
  Serial.println(RangePotValue);             // print the rangefinder value back to the debugger pane
  delay(10);                                 // wait 10 milliseconds before the next loop



  if(RangePotValue &lt;= 125) {                // if the rangefinder detects something in range
    digitalWrite(blinkyPin, HIGH);          // turn the light on
    digitalWrite(onOffPin, LOW);            // turn the speakers off
    Serial.println("detected");             // print "detected"

    delay(100);
  } 
  else {
    digitalWrite(blinkyPin, LOW);          // if the rangefinder doesn't detect anything
    digitalWrite(onOffPin, HIGH);          // leave the speakers connected
    Serial.println("not detected");        // print "not detected"
  } 

}

void blinky() {
  int i;
  int blinks = 0;

  for (i=0;i&lt;=blinks;i++) {
    digitalWrite(blinkyPin, HIGH);
    delay(500);
    digitalWrite(blinkyPin, LOW);
    delay(500);
  }
}</description>
		<content:encoded><![CDATA[<p>Finally modified!</p>
<p>/*<br />
Concrete Crickets Arduino Code<br />
 Michael J. Dory<br />
 <a href="http://www.doryexmachina.com" rel="nofollow">http://www.doryexmachina.com</a><br />
 Written 04.11.07, revised 11.02.07<br />
 (thanks to code from Tom Igoe, Clay Shirky and Rob Faludi)<br />
 */</p>
<p>int RangePotPin = 5;    // Analog input pin that the rangefinder is attached to<br />
int RangePotValue = 0;   // value read from the pot</p>
<p>int MP3Pin = 12;    // the pin that the relay controlling the MP3 is attached to </p>
<p>int blinkyPin = 13; // the pin that the reference LED is attached to</p>
<p>int onOffPin = 11; //the pin that the speaker attach/kill switch relay is on.</p>
<p>void setup() {<br />
  // initialize serial communications at 9600 bps:<br />
  Serial.begin(9600); </p>
<p>  // set pins for output<br />
  pinMode(blinkyPin, OUTPUT);<br />
  pinMode(onOffPin, OUTPUT);<br />
  pinMode(MP3Pin, OUTPUT);</p>
<p>  // initialize both pins at low<br />
  digitalWrite(MP3Pin, LOW);<br />
  digitalWrite(blinkyPin, LOW);</p>
<p>  delay(100);</p>
<p>  // turn MP3 Player on, blink pin 13 for reference<br />
  digitalWrite(MP3Pin, HIGH);<br />
  digitalWrite(blinkyPin, HIGH);<br />
  delay(5000);</p>
<p>  // take both pins low again<br />
  digitalWrite(MP3Pin, LOW);<br />
  digitalWrite(blinkyPin, LOW);</p>
<p>  delay(100);</p>
<p>  // blink LED three times quickly to show mp3 player is on<br />
  blinky();</p>
<p>  // start playing the MP3<br />
  delay (2000);<br />
  digitalWrite(MP3Pin, HIGH);<br />
  digitalWrite(blinkyPin, HIGH);<br />
  delay(500);<br />
  digitalWrite(MP3Pin, LOW);<br />
  digitalWrite(blinkyPin, LOW);</p>
<p>  // blink three times to show that the MP3 player is playing and setup is complete<br />
  blinky();</p>
<p>  // end setup<br />
}</p>
<p>void loop() {<br />
  RangePotValue = analogRead(RangePotPin);   // read the pot value<br />
  Serial.println(RangePotValue);             // print the rangefinder value back to the debugger pane<br />
  delay(10);                                 // wait 10 milliseconds before the next loop</p>
<p>  if(RangePotValue <= 125) {                // if the rangefinder detects something in range<br />
    digitalWrite(blinkyPin, HIGH);          // turn the light on<br />
    digitalWrite(onOffPin, LOW);            // turn the speakers off<br />
    Serial.println(&#8221;detected&#8221;);             // print &#8220;detected&#8221;</p>
<p>    delay(100);<br />
  }<br />
  else {<br />
    digitalWrite(blinkyPin, LOW);          // if the rangefinder doesn&#8217;t detect anything<br />
    digitalWrite(onOffPin, HIGH);          // leave the speakers connected<br />
    Serial.println(&#8221;not detected&#8221;);        // print &#8220;not detected&#8221;<br />
  } </p>
<p>}</p>
<p>void blinky() {<br />
  int i;<br />
  int blinks = 0;</p>
<p>  for (i=0;i<=blinks;i++) {<br />
    digitalWrite(blinkyPin, HIGH);<br />
    delay(500);<br />
    digitalWrite(blinkyPin, LOW);<br />
    delay(500);<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike.</title>
		<link>http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/#comment-8084</link>
		<dc:creator>mike.</dc:creator>
		<pubDate>Tue, 30 Oct 2007 22:28:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/#comment-8084</guid>
		<description>I hang my head in shame.  It absolutely will, I'm just crappy with arrays.  Fixing that up now, and will shortly post the new code.</description>
		<content:encoded><![CDATA[<p>I hang my head in shame.  It absolutely will, I&#8217;m just crappy with arrays.  Fixing that up now, and will shortly post the new code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clay Shirky</title>
		<link>http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/#comment-8082</link>
		<dc:creator>Clay Shirky</dc:creator>
		<pubDate>Tue, 30 Oct 2007 17:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.doryexmachina.com/itpblog/2007/10/30/final-crickets-code/#comment-8082</guid>
		<description>Won't creating a blink(pin, delay) function make you so happy?

for (i=0;i&#60;=blinks;i++) {
  digitalWrite(pin, HIGH);
  delay(delay);
  digitalWrite(pin, LOW);
  delay(delay);
}

Should cut the code in half, and make the blink handling more flexible, no?</description>
		<content:encoded><![CDATA[<p>Won&#8217;t creating a blink(pin, delay) function make you so happy?</p>
<p>for (i=0;i&lt;=blinks;i++) {<br />
  digitalWrite(pin, HIGH);<br />
  delay(delay);<br />
  digitalWrite(pin, LOW);<br />
  delay(delay);<br />
}</p>
<p>Should cut the code in half, and make the blink handling more flexible, no?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
