#include <SoftwareSerial.h>
#include <CapacitiveSensor.h>
/*
* CapitiveSense Library Demo Sketch
* 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
*/
SoftwareSerial mySerial(2, 3);
byte byteData;
CapacitiveSensor cs_8_5 = CapacitiveSensor(8,5); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_8_6 = CapacitiveSensor(8,6); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
CapacitiveSensor cs_8_9 = CapacitiveSensor(8,9); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
int note1 = 60;
int note2 = 62;
int note3 = 64;
byte note = 0;
byte resetMIDI = 4;
void setup()
{
cs_8_5.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);
mySerial.begin(31250);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
}
void loop()
{
long start = millis();
long total1 = cs_8_5.capacitiveSensor(200);
long total2 = cs_8_6.capacitiveSensor(200);
long total3 = cs_8_9.capacitiveSensor(200);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing
Serial.print(total1); // print sensor output 1
Serial.print("\t");
Serial.print(total2); // print sensor output 2
Serial.print("\t");
Serial.println(total3); // print sensor output 3
delay(10); // arbitrary delay to limit data to serial port
if(total1>100){
digitalWrite(10,HIGH);
delay(1);
noteOn(0, note1,100);
}
if(total2>100){
digitalWrite(11,HIGH);
delay(1);
noteOn(0, note2,100);
}
if(total3>100){
digitalWrite(12,HIGH);
delay(1);
noteOn(0, note3,0);
}
else
delay(1);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
digitalWrite(12,LOW);
noteOff(0, note1,0);
noteOff(0, note22,0);
noteOff(0, note33,0);
delay(10);
}
ex1.ino: In function 'void loop()':
ex1:56: error: 'noteOn' was not declared in this scope
ex1:61: error: 'noteOn' was not declared in this scope
ex1:66: error: 'noteOn' was not declared in this scope
ex1:73: error: 'noteOff' was not declared in this scope
I don't know why??????