Playing around with the clamshell stompbox, I used two sketches included in the Arduino examples to turn it into a functioning switch.
To make a momentary push-button switch, I used the sketch, “IfStatementConditional”, found in the “Control” examples.
This sketch was meant for a potentiometer, so I treated the clamshell stompbox as one half of the potentiometer, and used a fixed resistor for the other half.
First I found a fixed resistor that had about the same resistance clamshell—10K Ohm. I connected the fixed resistor between A0 and ground.
Then I connected one lead of the clamshell, also to A0. (Since I was using test leads, I just clipped directly to the fixed resistor leg coming out of A0. This way I could skip the breadboard.) I connected the other clamshell lead to 5V, then uploaded the sketch.
The result: the built-in LED light on pin 13 lit up whenever I pressed on the clamshell.
If you have trouble with this:
Open the serial monitor (the little magnifying glass icon in at the top of the arduino sketch). Note the numbers that appear each time you tap the switch.
Those numbers should be higher than the threshold value in the sketch. If they aren’t, lower the value. This number tells the Arduino the point at which to turn on the LED.
I want the clamshell to behave like a real stompbox, so I decided to make a toggle switch next. I used the sample sketch, “Knock”, from the “Sensors” examples.
This uses the same wiring as the “IfStatementConditional” above. However, before I loaded the sketch, I changed
Serial.println(“Knock!”);
To
(This change allows me to see the numbers the Arduino reads off the clamshell.)
After verifying and loading the sketch, I opened the serial monitor. Now every time I tapped on the clamshell, the built-in LED on pin 13 toggled on or off. Additionally, the sensor reading itself appeared in the serial monitor.
It worked well, but I noticed the monitor sometimes returned several readings for each tap, or none at all. So I played with the delay value, and varied how fast I was hitting the switch. That seemed to do the trick.
Just like with the first sketch, the threshold value is key: If it doesn’t work, make sure the number assigned to “threshold” is much lower than the sensor reading numbers in the monitor.
[edit: I've posted the entire how-to on Instructables. Please find it here. ]