# CapacitiveSensor error

**URL:** <https://forum.arduino.cc/t/capacitivesensor-error/170956>\
**Category:** Sensors\
**Created:** [July 1, 2013, 4:32am UTC](https://forum.arduino.cc/t/capacitivesensor-error/170956 "2013-07-01T04:32:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [July 1, 2013, 4:32am UTC](https://forum.arduino.cc/t/capacitivesensor-error/170956/1 "2013-07-01T04:32:37Z")

</div>

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** () {  
> **Serial**.begin(9600);  
> pinMode(ledPin, OUTPUT);  
> }  
> void **loop** () {  
> long sensorValue = capSensor.capacitiveSensor(30);  
> **Serial**.println(sensorValue);  
> if(sensorValue \> threshold) {  
> digitalWrite(ledPin, HIGH);  
> }  
> else {  
> digitalWrite(ledPin, LOW);  
> }  
> delay(10);  
> }

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 ([Arduino Playground - HomePage](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?

---

<div class="post-metadata">

**Author:** ![johnwasser](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnwasser/32/214270_2.png) [@johnwasser](https://forum.arduino.cc/u/johnwasser)\
**Post date:** [July 1, 2013, 2:56pm UTC](https://forum.arduino.cc/t/capacitivesensor-error/170956/2 "2013-07-01T14:56:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 10:02am UTC](https://forum.arduino.cc/t/capacitivesensor-error/170956/3 "2021-05-06T10:02:02Z")

</div>

Closed on May 6, 2021, 10:02am UTC


