2

I'm trying to work with the CapSense library for Arduino. However, I can't manage to run the example included with the package, called "CapSenseSketch". When I try just opening the file and running it (I've tried both Arduino 1.0 and 1.0.1), I get a compiler error that says 'CapSense does not name a type", and also

CapSenseSketch.cpp:1:22: error: CapSense.h: No such file or directory
CapSenseSketch:11: error: 'CapSense' does not name a type
CapSenseSketch:12: error: 'CapSense' does not name a type
CapSenseSketch:13: error: 'CapSense' does not name a type
CapSenseSketch.cpp: In function 'void setup()':
CapSenseSketch:17: error: 'cs_4_2' was not declared in this scope
CapSenseSketch.cpp: In function 'void loop()':
CapSenseSketch:24: error: 'cs_4_2' was not declared in this scope
CapSenseSketch:25: error: 'cs_4_6' was not declared in this scope
CapSenseSketch:26: error: 'cs_4_8' was not declared in this scope

There is an include statement at the top of the code,

#include <CapSense.h>

and I thought that would be the problem, so I changed the brackets to quotes and still got an error saying "Error compiling" and:

CapSenseSketch.cpp.o: In function `__static_initialization_and_destruction_0':
CapSenseSketch.cpp:15: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp:16: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp:17: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp.o: In function `loop':
CapSenseSketch.cpp:28: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp:29: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp:30: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp.o: In function `setup':
CapSenseSketch.cpp:21: undefined reference to `CapSense::set_CS_AutocaL_Millis(unsigned long)'

Any ideas? I've worked with CapSense on another computer and changing the brackets to quotes worked fine that time, but it doesn't seem to be doing much now.

Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
user1549824
  • 51
  • 1
  • 4
  • Are you getting the errors when you check the syntax or when you try to compile and upload? – huck.treadwell Jul 25 '12 at 03:55
  • Just when I press 'verify'. I fixed the problem yesterday, though. In the arduino IDE, to use external scripts, you have to go to "sketch > add file" for every file you want to use. In my case, I was using a .h file, and a .cpp file that the .h file used. I had only added the .h file in this way, so the arduino wasn't seeing the necessary code in the .cpp file, though it was included in the .h file. – user1549824 Jul 26 '12 at 13:54
  • Also, for anyone using CapSense004, the type was renamed to CapacitiveSensor from CapSense. – J Set Mar 12 '13 at 02:03

1 Answers1

3

Apparently including external files works a bit differently in the arduino ide. It's not enough to simply have an include statement at the top of your code, you must instead manually go to sketch > add file for every external file you want to use. In my case, I only did this for one out of the two files I was trying to use.

user1549824
  • 51
  • 1
  • 4