Capacitive Sensor without serial read

Hi All,

I have an interest in making touch sensitive lamp. i created the circuit a described in the reference section of the website along with using the library for a capacitive touch sensor and got it to work. Attached is the code I wrote if it is helpful.

My query is, is it possible to make this sort of thing with having to be permanently attached to a computer to write back to all the time?

Thanks in advance,
Danny

Touchy_Feely_Step.ino (1.02 KB)

Hi Danny

The data being written to the serial port in this case is for testing the program. You could delete the serial statements to be tidy, or leave them in and don't use serial monitor on the PC - the program will work without it.

You could then power the Arduino from a power source other than the USB port on a PC, if that's what you had in mind.

Regards

Ray

Hi Ray,

Firstly, thanks for the reply. Second, that now works! :slight_smile: any ideas on debouncing it?
Thanks
Danny

When is the bounce happening exactly, Danny?

Hi Ray,

Sorry the the long wait.
When i touch the sensor sometimes it steps the counter on more than once but i cant work it out from the serial read because they all appear in a long line, once after another making it hard to differentiate the individual numbers

Thanks
Danny

Try changing this part of your code in loop() - it should make it easier to see when the bounce happens.

   // Serial.print(sensorValue);  COMMENT OUT TO AVOID LOTS OF VALUES BEING PRINTED
   if (sensorValue >threshold){
     counter += 1;
     if (counter == 4){
       counter = 0;
     }
     Serial.println(counter); // ADD TO PRINT OUT COUNTER ONLY WHEN IT CHANGES
     delay(30);
     etc