Any advice appreciated.
As a novice I can't work out why these errors come up when I try to verify the sketch downloaded form the page linked above:
sketch_jan23capsense:13: error: 'CapacitiveSensor' does not name a type
sketch_jan23capsense:14: error: 'CapacitiveSensor' does not name a type
sketch_jan23capsense:15: error: 'CapacitiveSensor' does not name a type
sketch_jan23capsense.ino: In function 'void setup()':
sketch_jan23capsense:20: error: 'cs_4_2' was not declared in this scope
sketch_jan23capsense.ino: In function 'void loop()':
I am using a macbook with 10.9.1, other sketches work fine, and I have reverted to earlier firmware to ensure sketches upload OK.
#include <CapacitiveSensor.h>
/*
* CapitiveSense Library Demo Sketch
* Paul Badger 2008
* Uses a high value resistor e.g. 10 megohm between send pin and receive pin
* Resistor effects sensitivity, experiment with values, 50 kilohm - 50 megohm. Larger resistor values yield larger sensor values.
* Receive pin is the sensor pin - try different amounts of foil/metal on this pin
* Best results are obtained if sensor foil and wire is covered with an insulator such as paper or plastic sheet
*/
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
CapacitiveSensor cs_4_5 = CapacitiveSensor(4,5); // 10 megohm resistor between pins 4 & 6, pin 6 is sensor pin, add wire, foil
CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8); // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil
void setup()
{
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
long total2 = cs_4_5.capacitiveSensor(30);
long total3 = cs_4_8.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug window 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
}
i am Having the same problem extracted the capacitiveSensor.zip file into the libraries folder where my sketches are but getting error messages
can anyone help please
Hi Paul i just wondered if anyone could help with the capsense issue i and a few more are having
this is the code and errors thank you
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include <CapacitiveSensor.h>
/*
CapitiveSense Library Demo Sketch
Paul Badger 2008
Uses a high value resistor e.g. 10M between send pin and receive pin
Receive pin is the sensor pin - try different amounts of foil/metal on this pin
*/
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
void setup()
{
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
long total2 = cs_4_6.capacitiveSensor(30);
long total3 = cs_4_8.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing
delay(10); // arbitrary delay to limit data to serial port
}
errors are
capacitiveSensorSketch:12: error 'capacitiveSensor' does not name a type
capacitiveSensorSketch:13: error 'capacitiveSensor' does not name a type
capacitiveSensorSketch:14: error 'capacitiveSensor' does not name a type
capacitiveSensorSketch.pde: in function 'void setup() ' ;
capacitiveSensorSketch:18: error 'cs_4_2' was not declared in this scope
capacitiveSensorSketch.pde: in function 'void loop()' :
capacitiveSensorSketch:25: error 'cs_4_2' was not declared in this scope
capacitiveSensorSketch:26: error 'cs_4_6' was not declared in this scope
capacitiveSensorSketch:27: error 'cs_4_8' was not declared in this scope
hi thanks for that well can you or anyone tell me where i am going wrong please i restarted the ide and followed someone elses advice and unzipped the files into Arduino / libraries but still no joy if anyone can help id really appreciate it thanks.
You should have a libraries folder in the folder where you store your sketches. If not, create one.
Open the zip file. There is a single folder in it. Open that folder. It contains two more folders. Drag the CapacitiveSensor folder to the libraries folder in your sketch folder.
In my case, that results in C:\Users\PaulS\Arduino\libraries\CapacitiveSensor containing CapacitiveSensor.h, CapacitiveSensor .cpp, keywords.txt, a Readme file, and an examples folder.