Arduino capsense noise box

Geek, Lighting Tech, Maker

Arduino capsense noise box

This requires the Arduino capsense library!!!

 
 
 
#include <CapacitiveSensor.h>

/*
* CapitiveSense Library Music Box
* Coded By: CPYarger 2013
* Library built by Paul Badger 2008
* Uses a high value resistor e.g. 10M between send pin and receive pin
* Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
* Receive pin is the sensor pin - try different amounts of foil/metal on this pin
*/



CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil


void setup()
{

Serial.begin(9600);
}

void loop()
{
long start = millis();

long total2 = cs_4_6.capacitiveSensor(30);

Serial.println(total2);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("t"); // tab character for debug windown spacing

if (total2 > 50){

tone(8,total2/2);
long total3 = (total2*2);
tone(8,total3);
tone(8,total3*30);
tone(8,total2*10);
};

noTone(8);
Serial.println(total2); // print sensor output 2

}

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.