Go Down

Topic: CapacitiveSensor error (Read 1 time) previous topic - next topic


Arduino type: Arduino UNO Via "The Arduino Starter Kit"
Arduino IDE code: 1.0.5 Primary/1.5.2 troubleshooting/ 0022 Alpha troublshooting

Code trying to compile: Project 13 from Arduino Projects book


#include <CapacitiveSensor.h>
CapacitiveSensor capSensor = CapacitiveSensor(4,2);
int threshold = 1000;
const int ledPin = 12;
void setup() {
  pinMode(ledPin, OUTPUT);
void loop() {
  long sensorValue = capSensor.capacitiveSensor(30);
  if(sensorValue > threshold) {
    digitalWrite(ledPin, HIGH);
  else {
    digitalWrite(ledPin, LOW);

Error being received

p13:2: error: 'CapacitiveSensor' does not name a type
p13.ino: In function 'void loop()':
p13:10: error: 'capSensor' was not declared in this scope

I'm not the only person getting this issue for the class that I'm doing this for. I'm looking for a solution to this problem. I'm not a debugger, so trying to do that isn't feasible for me. I did follow instructions on how to install the library (http://playground.arduino.cc//Main/CapacitiveSensor?from=Main.CapSense) and even the example code errors out.

Example error code:

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

It looks like the IDE just does not have the type for capsense at all. What will I need to do to fix this?


It compiles fine for me.  Did you take the folder "arduino-libraries-CapacitiveSensor-3e33f75/libraries/CapacitiveSensor" and put that in your Arduino/libraries folder?  Did you re-start the IDE?
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131