[MakeLV] How Exciting!

Mark mstanley at technologist.com
Thu Nov 4 19:25:34 CDT 2010


On Thursday 04 November 2010 10:03:00 Josiah Ritchie wrote:
> I'd also like to have my circuits reviewed by someone who knows what their
> doing in that world to point out why I have some quirks. For example, if I
> have all my pots high, it doesn't operate as expected and I think this is
> because it's just sucking too much power, but I don't know what I can do
> about that. Debouncing the buttons would probably be a good idea.

 I can help with this and is exactly the reason I've been waiting for a 
Maker/Hacker space to start up. 

 I looked at the source code in Tests.pde and found the following:

  if (leftEar.isPressed()) earCondition = 1;
  if (rightEar.isPressed()) earCondition = 2;
  if (rightEar.isPressed() && leftEar.isPressed()) earCondition = 0;


This is where you can add button debouncing.  If you encapsulate those three lines 
inside a timer test you can "slow down" button testing without slowing down the 
rest of the loop().

I'm kind of rushing through this because I'm supposed to be doing my Calculus 
homework.  So it's not tested:

------- Non-blocking Debounce ----------------------------

//  A static variable retains its value between calls.
static unsigned long delay_timer = 0;

if ( (millis() - delay_timer) > 50)  //  For best results try different values.
{
	if (leftEar.isPressed()) earCondition = 1;
	if (rightEar.isPressed()) earCondition = 2;
	if (rightEar.isPressed() && leftEar.isPressed()) earCondition = 0;
	delay_timer = millis();
}
------------------------------------------------------------------

-Mark Stanley

P.S.  I have to install Eagle before I can look at the schematic or would you be 
amenable to exporting it to PDF?





More information about the MakeLehighValley mailing list