I'm trying to compile and upload a capacitive sensor LED keyboard, but when the IDE tries to compile, it throws up an error message:
-----------------------------------------------------------------<
Arduino: 1.6.4 (Windows 7), Board: "Arduino Uno"
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard C:\Users\Josh\AppData\Local\Temp\build2046831816545020170.tmp\capacitive_music.cpp -o C:\Users\Josh\AppData\Local\Temp\build2046831816545020170.tmp\capacitive_music.cpp.o
capacitive_music.ino:1:30: fatal error: CapacitiveSensor.h: No such file or directory
compilation terminated.
Error compiling.
-----------------------------------------------------------------<
I just downloaded the 1.6.4 version and it doesn't work. It worked before, but I don't remember which version I had.
My guess is that you don't have the CapacitiveSensor library file in the right place. Check and make sure you have it in the right place and the subdirectory is named CapacitiveSensor.
That worked-kinda. It no longer throws up an error. Now it just doesn't compile. The compiling loading bar just sits there at about 1/4. After about fifteen minutes there's no change.
oh and this is what is written in the text area while the compilation is loading:
--------------------------------------------------------------<
Using library CapacitiveSensor in folder: C:\Users\Josh\Desktop\arduino-1.6.4\libraries\CapacitiveSensor (legacy)
C:\Users\Josh\Desktop\arduino-1.6.4\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\Josh\Desktop\arduino-1.6.4\hardware\arduino\avr\cores\arduino -IC:\Users\Josh\Desktop\arduino-1.6.4\hardware\arduino\avr\variants\standard -IC:\Users\Josh\Desktop\arduino-1.6.4\libraries\CapacitiveSensor C:\Users\Josh\AppData\Local\Temp\build457052940502204785.tmp\capmusic.cpp -o C:\Users\Josh\AppData\Local\Temp\build457052940502204785.tmp\capmusic.cpp.o
--------------------------------------------------------------<
There's a new cpp file called capmusic, which suggests another library. It's time to post all of your code. Make sure you use code tags and Ctrl-T in the IDE to standard format your code before posting. If you need help, read Nick Gammon's two posts at the top of this Forum.
Here's my code:
#include <CapacitiveSensor.h>
CapacitiveSensor capSensor1 = CapacitiveSensor(0, 1);
CapacitiveSensor capSensor2 = CapacitiveSensor(4, 3);
CapacitiveSensor capSensor3 = CapacitiveSensor(7, 6);
CapacitiveSensor capSensor4 = CapacitiveSensor(10, 9);
int threshold = 1000;
const int ledPin1 = 2;
const int ledPin2 = 5;
const int ledPin3 = 8;
const int ledPin4 = 11;
void setup() {
Serial.begin(9600)
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
}
void loop() {
long sensorValue1 = capSensor1(30);
long sensorValue2 = capSensor2(30);
long sensorValue3 = capSensor3(30);
long sensorValue4 = capSensor4(30);
Serial.print(sensorValue1, "|", sensorValue2, "|", sensorValue3, "|", sensorValue4);
if (sensorValue1 > threshold) {
digitalWrite(ledPin1, HIGH);
}
else digitalWrite(ledPin1, LOW);
}
I hope this helps
What are the arguments for the CapacitiveSensor instances? If those are pin numbers, you need to get that sensor off of the hardware serial port - at least while compiling and loading. If you are going to put the sensor back on pins 0 and 1, get rid of the Serial.begin() statement and any other uses of Serial.
Yes the CapacitiveSensor() arguments are pins.
I also got rid of the serial stuff, and now it compiles, but it throws up another error: "no match for call to '(CapacitiveSensor) (int)' "
Here's the long error message:
------------------------------------------<
Arduino: 1.6.4 (Windows 7), Board: "Arduino Uno"
Using library CapacitiveSensor in folder: C:\Users\Josh\Desktop\arduino-1.6.4\libraries\CapacitiveSensor (legacy)
C:\Users\Josh\Desktop\arduino-1.6.4\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Users\Josh\Desktop\arduino-1.6.4\hardware\arduino\avr\cores\arduino -IC:\Users\Josh\Desktop\arduino-1.6.4\hardware\arduino\avr\variants\standard -IC:\Users\Josh\Desktop\arduino-1.6.4\libraries\CapacitiveSensor C:\Users\Josh\AppData\Local\Temp\build457052940502204785.tmp\capmusic.cpp -o C:\Users\Josh\AppData\Local\Temp\build457052940502204785.tmp\capmusic.cpp.o
capmusic.ino: In function 'void loop()':
capmusic.ino:21:36: error: no match for call to '(CapacitiveSensor) (int)'
capmusic.ino:22:36: error: no match for call to '(CapacitiveSensor) (int)'
capmusic.ino:23:36: error: no match for call to '(CapacitiveSensor) (int)'
capmusic.ino:24:36: error: no match for call to '(CapacitiveSensor) (int)'
no match for call to '(CapacitiveSensor) (int)'
------------------------------------------<
What do YOU think that capSensor1(30) is supposed to do? capSensor1 is an instance of the CapacitiveSensor class. It is used to call methods of the class. The usual format for doing that is instanceName.method(arguments).
Serial.print(sensorValue1, "|", sensorValue2, "|", sensorValue3, "|", sensorValue4);
Nonsense. The print() method does not take 7 arguments.