<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Spooky Arduino Projects #4 &#8211; Musical Arduino</title>
	<atom:link href="http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/</link>
	<description>Random experiments, circuits, code, rapid prototyping, sometimes things to buy, and the odd tune by Tod E. Kurt.</description>
	<lastBuildDate>Thu, 11 Mar 2010 14:51:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Seb</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-11/#comment-63140</link>
		<dc:creator>Seb</dc:creator>
		<pubDate>Thu, 11 Mar 2010 12:04:31 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-63140</guid>
		<description>Awesome, Thanks for the post - I&#039;ve just started playing with piezos and this has proved to be great inspiration!</description>
		<content:encoded><![CDATA[<p>Awesome, Thanks for the post &#8211; I&#8217;ve just started playing with piezos and this has proved to be great inspiration!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: doktormtl</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-11/#comment-59566</link>
		<dc:creator>doktormtl</dc:creator>
		<pubDate>Tue, 16 Feb 2010 04:20:39 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-59566</guid>
		<description>Hey thanks for great tutorials, I am using the USB to connect the arduino to my Mac. I keep getting piano sounds when I run it thru garageband even when I change the instrument. Is there something in the sketch I should address?</description>
		<content:encoded><![CDATA[<p>Hey thanks for great tutorials, I am using the USB to connect the arduino to my Mac. I keep getting piano sounds when I run it thru garageband even when I change the instrument. Is there something in the sketch I should address?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: todbot</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-11/#comment-58872</link>
		<dc:creator>todbot</dc:creator>
		<pubDate>Tue, 02 Feb 2010 18:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58872</guid>
		<description>Hi Alessio,
Yes, in theory because there is that spinloop, there is the possibility of large delays between notes (&quot;flam&quot;).  In practice, the pulse from the piezos is usually very short, on the order of a few microseconds.  The &quot;delay(t)&quot; in the code between noteOn and noteOff is probably not necessary for most sound modules in drum trigger mode.  I just did it because I come from the land of old MIDI hardware where that wouldn&#039;t work. ;) 

If you are concerned about the delays though, the sketch could be changed so instead of doing a spinloop and delay, it maintains an &quot;is_triggered&quot; state for each piezo, then checks and increments an individual &quot;t&quot; value for each piezo.  Then you read all the piezos at once, and then decide to send midiOn or not.</description>
		<content:encoded><![CDATA[<p>Hi Alessio,<br />
Yes, in theory because there is that spinloop, there is the possibility of large delays between notes (&#8220;flam&#8221;).  In practice, the pulse from the piezos is usually very short, on the order of a few microseconds.  The &#8220;delay(t)&#8221; in the code between noteOn and noteOff is probably not necessary for most sound modules in drum trigger mode.  I just did it because I come from the land of old MIDI hardware where that wouldn&#8217;t work. ;) </p>
<p>If you are concerned about the delays though, the sketch could be changed so instead of doing a spinloop and delay, it maintains an &#8220;is_triggered&#8221; state for each piezo, then checks and increments an individual &#8220;t&#8221; value for each piezo.  Then you read all the piezos at once, and then decide to send midiOn or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alessio</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-11/#comment-58868</link>
		<dc:creator>alessio</dc:creator>
		<pubDate>Tue, 02 Feb 2010 10:15:18 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58868</guid>
		<description>Thanks for the reply!

I was thinking to the worst case: when you hit two pads exactly at the same time or with a few microsecond delay . so i suppose that the piezo pulse (from threshold to threshold ) is a few millisecond long, right? .The code scans the first analog input, wait for a &quot;t&quot; time , send a midi on note, then wait for a &quot;t&quot; delay and then a midi off note. after that repeats the same procedure with analog input 2 ... so after hitting a pad there&#039;s at least 2t delay. In the worst case i mention above the second hit is completely lost. I am missing something? maybe i&#039;m too much pessimist, maybe the worst case happens very very rarely.

thanks, bye!</description>
		<content:encoded><![CDATA[<p>Thanks for the reply!</p>
<p>I was thinking to the worst case: when you hit two pads exactly at the same time or with a few microsecond delay . so i suppose that the piezo pulse (from threshold to threshold ) is a few millisecond long, right? .The code scans the first analog input, wait for a &#8220;t&#8221; time , send a midi on note, then wait for a &#8220;t&#8221; delay and then a midi off note. after that repeats the same procedure with analog input 2 &#8230; so after hitting a pad there&#8217;s at least 2t delay. In the worst case i mention above the second hit is completely lost. I am missing something? maybe i&#8217;m too much pessimist, maybe the worst case happens very very rarely.</p>
<p>thanks, bye!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: todbot</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-11/#comment-58865</link>
		<dc:creator>todbot</dc:creator>
		<pubDate>Mon, 01 Feb 2010 20:55:20 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58865</guid>
		<description>Hi Alessio,
Yes, the code scans just one at a time, but it does it very quickly so you can get the appearance of simultaneity.  So set your MIDI sound module to &quot;drum trigger&quot; mode (or increase the release time) so that the MIDI messages generate sustaining sounds on your sound module.</description>
		<content:encoded><![CDATA[<p>Hi Alessio,<br />
Yes, the code scans just one at a time, but it does it very quickly so you can get the appearance of simultaneity.  So set your MIDI sound module to &#8220;drum trigger&#8221; mode (or increase the release time) so that the MIDI messages generate sustaining sounds on your sound module.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alessio</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58864</link>
		<dc:creator>alessio</dc:creator>
		<pubDate>Mon, 01 Feb 2010 16:44:05 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58864</guid>
		<description>Hi!

very very good project!

I have just one simple question. Is this module polyphonic?
if i understand correctly the code the arduino scans just one analog input at time...

thanks, bye!</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>very very good project!</p>
<p>I have just one simple question. Is this module polyphonic?<br />
if i understand correctly the code the arduino scans just one analog input at time&#8230;</p>
<p>thanks, bye!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: porfyros</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58844</link>
		<dc:creator>porfyros</dc:creator>
		<pubDate>Fri, 29 Jan 2010 02:04:45 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58844</guid>
		<description>Hey!

I was looking for electronic drums in the DIY domain, and I found Wyatt&#039;s work. After a while I also discovered yours and found it really inspiring, and so I started my own implementation. 

Since there are people asking, there is a way to interface arduino with MIDI and Linux, through USB and no additional hardware, through ttymidi [1]. This is the road that I follow, and you can also check my progress in my blog! [2]

I believe that there are plenty of audio software solutions available for Linux, although it is still tricky to succeed in configuring everything smoothly.

-prf 

[1] - http://www.varal.org/ttymidi/
[2] - http://www.prfbase.com/porfyros/2010/01/e-tampourlo/</description>
		<content:encoded><![CDATA[<p>Hey!</p>
<p>I was looking for electronic drums in the DIY domain, and I found Wyatt&#8217;s work. After a while I also discovered yours and found it really inspiring, and so I started my own implementation. </p>
<p>Since there are people asking, there is a way to interface arduino with MIDI and Linux, through USB and no additional hardware, through ttymidi [1]. This is the road that I follow, and you can also check my progress in my blog! [2]</p>
<p>I believe that there are plenty of audio software solutions available for Linux, although it is still tricky to succeed in configuring everything smoothly.</p>
<p>-prf </p>
<p>[1] &#8211; <a href="http://www.varal.org/ttymidi/" rel="nofollow">http://www.varal.org/ttymidi/</a><br />
[2] &#8211; <a href="http://www.prfbase.com/porfyros/2010/01/e-tampourlo/" rel="nofollow">http://www.prfbase.com/porfyros/2010/01/e-tampourlo/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tjookum</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58821</link>
		<dc:creator>tjookum</dc:creator>
		<pubDate>Tue, 19 Jan 2010 16:48:47 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58821</guid>
		<description>Ive been researching the possibility&#039;s of serial to midi data sending and this has proven to be extremely usefull.

Ive succesfully connected 1 pot using a arduino mega, s2midi and midi yoke to ableton live. Although there was some latency it was barely noticable. The thing is, I want to use around 16 pots and 16 switches. Since my programming skills are far from perfect, ive run into some problems hacking the attached analogcc code from s2midi to accept multiple pots on different analog pins. Is there anyone who has tried this before and would like to share their code? 

here is the original code from their website:&lt;pre&gt;
// Example of Arduino feeding S2MIDI CC messages

int midiChannel = 9;
int outPin = 13;       // the number of the output pin
int analogPin = 5;

// Analog smoothing stuff
int lastAnalog = 0;
int analogSmooth = 2;  // Amount of change needed to send control change

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int reading = 0;

// Do analog line
  reading = analogRead(analogPin)/8; // change 0-1024 into 0-127
  if (abs(reading-lastAnalog) &gt; analogSmooth) {
    lastAnalog = reading;
    controlChange(midiChannel,10,reading);  // Send CC10
  }
}

// Send a MIDI control change
void controlChange(byte channel, byte controller, byte value) {
   midiMsg(channel+0xB0, controller, value);
}

// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
  digitalWrite(outPin,HIGH);  // indicate we&#039;re sending MIDI data
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
  digitalWrite(outPin,LOW);
}
&lt;/pre&gt;

Also, there have been several references to little-scale&#039;s blog and I&#039;ve been particulary interested in this entry:
http://little-scale.blogspot.com/2007/11/more-pots-and-switches-to-midi-data.html

maybe sometime...</description>
		<content:encoded><![CDATA[<p>Ive been researching the possibility&#8217;s of serial to midi data sending and this has proven to be extremely usefull.</p>
<p>Ive succesfully connected 1 pot using a arduino mega, s2midi and midi yoke to ableton live. Although there was some latency it was barely noticable. The thing is, I want to use around 16 pots and 16 switches. Since my programming skills are far from perfect, ive run into some problems hacking the attached analogcc code from s2midi to accept multiple pots on different analog pins. Is there anyone who has tried this before and would like to share their code? </p>
<p>here is the original code from their website:
<pre>
// Example of Arduino feeding S2MIDI CC messages

int midiChannel = 9;
int outPin = 13;       // the number of the output pin
int analogPin = 5;

// Analog smoothing stuff
int lastAnalog = 0;
int analogSmooth = 2;  // Amount of change needed to send control change

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  int reading = 0;

// Do analog line
  reading = analogRead(analogPin)/8; // change 0-1024 into 0-127
  if (abs(reading-lastAnalog) &gt; analogSmooth) {
    lastAnalog = reading;
    controlChange(midiChannel,10,reading);  // Send CC10
  }
}

// Send a MIDI control change
void controlChange(byte channel, byte controller, byte value) {
   midiMsg(channel+0xB0, controller, value);
}

// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
  digitalWrite(outPin,HIGH);  // indicate we're sending MIDI data
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
  digitalWrite(outPin,LOW);
}
</pre>
<p>Also, there have been several references to little-scale&#8217;s blog and I&#8217;ve been particulary interested in this entry:<br />
<a href="http://little-scale.blogspot.com/2007/11/more-pots-and-switches-to-midi-data.html" rel="nofollow">http://little-scale.blogspot.com/2007/11/more-pots-and-switches-to-midi-data.html</a></p>
<p>maybe sometime&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: todbot</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58806</link>
		<dc:creator>todbot</dc:creator>
		<pubDate>Wed, 13 Jan 2010 20:32:15 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58806</guid>
		<description>Hi rgm,
Linux is notorious for having poor infrastructure for audio and MIDI-like data. (speaking as a long-time Linux laptop user)

I suspect the easiest approach would be to have a small program that sits on the Arduino&#039;s serial port and sends/receives &lt;a href=&quot;http://opensoundcontrol.org/&quot; rel=&quot;nofollow&quot;&gt;OSC&lt;/a&gt; messages.  Many audio programs support OSC, which is kind of like MIDI over UDP if you&#039;ve never heard of it.  OSC is nice because it&#039;s very simple and very flexible.  And just &lt;a href=&quot;http://opensoundcontrol.org/implementations&quot; rel=&quot;nofollow&quot;&gt;look at all the stuff people have built for OSC&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>Hi rgm,<br />
Linux is notorious for having poor infrastructure for audio and MIDI-like data. (speaking as a long-time Linux laptop user)</p>
<p>I suspect the easiest approach would be to have a small program that sits on the Arduino&#8217;s serial port and sends/receives <a href="http://opensoundcontrol.org/" rel="nofollow">OSC</a> messages.  Many audio programs support OSC, which is kind of like MIDI over UDP if you&#8217;ve never heard of it.  OSC is nice because it&#8217;s very simple and very flexible.  And just <a href="http://opensoundcontrol.org/implementations" rel="nofollow">look at all the stuff people have built for OSC</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rgm</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58805</link>
		<dc:creator>rgm</dc:creator>
		<pubDate>Wed, 13 Jan 2010 20:23:07 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58805</guid>
		<description>In the spirit of open source and small resource consumption, do you know a way to trigger sound samples on GNU/Linux with MIDI events with a small command line program?  Short of compiling my own SoundFont, I was unable to find anything small that would work well head-less or on embedded systems like the NSLU2.  For larger systems, these packages (in conjunction with a properly configured MIDI-&gt;USB gizmo) seem like they would work:
http://www.hydrogen-music.org/
http://ardour.org/

Of course there are many ways for an Arduino to signal a computer (serial, ethernet, midi...), but I&#039;m specifically interested in using MIDI messages for a velocity-sensitive soundboard (fartbonker-type) application, while not spending $500+ on proprietary software.

I can see why Ladyada made the WaveShield -- compact, low power, low-resource audio is a PITA with Arduino.</description>
		<content:encoded><![CDATA[<p>In the spirit of open source and small resource consumption, do you know a way to trigger sound samples on GNU/Linux with MIDI events with a small command line program?  Short of compiling my own SoundFont, I was unable to find anything small that would work well head-less or on embedded systems like the NSLU2.  For larger systems, these packages (in conjunction with a properly configured MIDI-&gt;USB gizmo) seem like they would work:<br />
<a href="http://www.hydrogen-music.org/" rel="nofollow">http://www.hydrogen-music.org/</a><br />
<a href="http://ardour.org/" rel="nofollow">http://ardour.org/</a></p>
<p>Of course there are many ways for an Arduino to signal a computer (serial, ethernet, midi&#8230;), but I&#8217;m specifically interested in using MIDI messages for a velocity-sensitive soundboard (fartbonker-type) application, while not spending $500+ on proprietary software.</p>
<p>I can see why Ladyada made the WaveShield &#8212; compact, low power, low-resource audio is a PITA with Arduino.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: todbot</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58662</link>
		<dc:creator>todbot</dc:creator>
		<pubDate>Wed, 09 Dec 2009 00:13:40 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58662</guid>
		<description>Hannes, are your pushbuttons wired up exactly as in the diagram in the post?  The sketch expects them wired up so a LOW indicates a button press.</description>
		<content:encoded><![CDATA[<p>Hannes, are your pushbuttons wired up exactly as in the diagram in the post?  The sketch expects them wired up so a LOW indicates a button press.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hannes</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58661</link>
		<dc:creator>Hannes</dc:creator>
		<pubDate>Tue, 08 Dec 2009 23:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58661</guid>
		<description>What a great project. 
I just have a little problem. When I press the pushbutton the sound stops and if I release it, it plays. So kind of upside down. Even if I exactly use your code.
Can anybody help me?
Thanks.</description>
		<content:encoded><![CDATA[<p>What a great project.<br />
I just have a little problem. When I press the pushbutton the sound stops and if I release it, it plays. So kind of upside down. Even if I exactly use your code.<br />
Can anybody help me?<br />
Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gadget</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-58112</link>
		<dc:creator>Gadget</dc:creator>
		<pubDate>Tue, 24 Nov 2009 00:12:17 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-58112</guid>
		<description>Hi Sebastian

Thanks for sharing!

Although I didn&#039;t understand this part of your code- could you assist please?

&quot;....if(val 127)....&quot;

and 


&quot;...noteOn(drumchan,note_bassdrum, output)....&quot;

(what is the output in this case?)

Thanks, and great work todbot!</description>
		<content:encoded><![CDATA[<p>Hi Sebastian</p>
<p>Thanks for sharing!</p>
<p>Although I didn&#8217;t understand this part of your code- could you assist please?</p>
<p>&#8220;&#8230;.if(val 127)&#8230;.&#8221;</p>
<p>and </p>
<p>&#8220;&#8230;noteOn(drumchan,note_bassdrum, output)&#8230;.&#8221;</p>
<p>(what is the output in this case?)</p>
<p>Thanks, and great work todbot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-57764</link>
		<dc:creator>Sebastian</dc:creator>
		<pubDate>Thu, 12 Nov 2009 20:51:12 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-57764</guid>
		<description>Hey.

Thanks for the code to this piezo trigger!
I&#039;ve actually made it better and I wanted to share that with you all.

I&#039;ve commented the code as good as I&#039;m able to.
One thing though: It does not send an OFF message to Logic, or Logic does not interpret it that way, it just interprets it like a zero velocity hit. Don&#039;t know why, really.
Please get back to me if you have the answer.

Anyway, this works perfectly for me:
&lt;pre&gt;
// what midi channel we&#039;re sending on
// ranges from 0-15
#define drumchan           1

// general midi drum notes
#define note_bassdrum     36

// define the pins we use
#define piezoAPin  0
#define ledPin     13  // for midi out status

// analog threshold for piezo sensing
#define PIEZOTHRESHOLD 80

int val;
int output;

void setup() 
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(31250);   // set MIDI baud rate
}


void loop() 
{
  static int prevval;
  
  //read analog signal from piezo.
  val = analogRead(piezoAPin);
  
  //if the analogue value exceeds the threshold, engage the if statement.
  if(val&gt;=PIEZOTHRESHOLD)
  {
    //add the value to a static variable to keep the previous analogue read value from last loop repetition.
    prevval+=val;
    
    //when the previous value is larger than the current value, we&#039;ve detected a peak in the analogue signal.
    if(val 127)
      {
        noteOn(drumchan,note_bassdrum, 127);
      }
      //in all other cases, the value will be the calculated value.
      else
      {
        noteOn(drumchan,note_bassdrum, output);
      }
      //when MIDI output is set, deactivate the MIDI signal again and reset the &#039;previous&#039; value to 0 to be ready for a new peak.
      noteOff(drumchan,note_bassdrum,0);
      prevval=0;
      //and finally a short delay for not overflowing the UART.
      delay(100);
    }
    
  } 
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hey.</p>
<p>Thanks for the code to this piezo trigger!<br />
I&#8217;ve actually made it better and I wanted to share that with you all.</p>
<p>I&#8217;ve commented the code as good as I&#8217;m able to.<br />
One thing though: It does not send an OFF message to Logic, or Logic does not interpret it that way, it just interprets it like a zero velocity hit. Don&#8217;t know why, really.<br />
Please get back to me if you have the answer.</p>
<p>Anyway, this works perfectly for me:</p>
<pre>
// what midi channel we're sending on
// ranges from 0-15
#define drumchan           1

// general midi drum notes
#define note_bassdrum     36

// define the pins we use
#define piezoAPin  0
#define ledPin     13  // for midi out status

// analog threshold for piezo sensing
#define PIEZOTHRESHOLD 80

int val;
int output;

void setup()
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(31250);   // set MIDI baud rate
}

void loop()
{
  static int prevval;

  //read analog signal from piezo.
  val = analogRead(piezoAPin);

  //if the analogue value exceeds the threshold, engage the if statement.
  if(val&gt;=PIEZOTHRESHOLD)
  {
    //add the value to a static variable to keep the previous analogue read value from last loop repetition.
    prevval+=val;

    //when the previous value is larger than the current value, we've detected a peak in the analogue signal.
    if(val 127)
      {
        noteOn(drumchan,note_bassdrum, 127);
      }
      //in all other cases, the value will be the calculated value.
      else
      {
        noteOn(drumchan,note_bassdrum, output);
      }
      //when MIDI output is set, deactivate the MIDI signal again and reset the 'previous' value to 0 to be ready for a new peak.
      noteOff(drumchan,note_bassdrum,0);
      prevval=0;
      //and finally a short delay for not overflowing the UART.
      delay(100);
    }

  }
}</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: xBot.es - Robotica aplicada</title>
		<link>http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/comment-page-10/#comment-57020</link>
		<dc:creator>xBot.es - Robotica aplicada</dc:creator>
		<pubDate>Mon, 26 Oct 2009 19:58:15 +0000</pubDate>
		<guid isPermaLink="false">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/#comment-57020</guid>
		<description>[...] y principalmente a esta de TodBot que es donde he sacado tanto esquemas como programación&#8230;. http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/  [...]</description>
		<content:encoded><![CDATA[<p>[...] y principalmente a esta de TodBot que es donde he sacado tanto esquemas como programación&#8230;. <a href="http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/" rel="nofollow">http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/</a>  [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
