I'm trying to fix a problem on my first larger Arduino UNO project. I'm using capacitive sensing for a 7-button control panel. Each button is an object of a class similar to the http://playground.arduino.cc//Main/CapacitiveSensor
library, with custom smoothing and debouncing. It only uses digital I/O. I've tuned it so it doesn't consume many CPU cycles for measuring, the baseline(while not touching) is usually around 150.
The problem is, that one of the buttons behaves as if it was always pressed, with occasional random releases. I've tried to use other pins on Arduino, with no change, so it appears as a hardware problem of the control panel. It's made of pieces of aluminium foil on paper connected to the Arduino by a ribbon cable.
The strangest thing, however, is that as long as the Arduino is connected to a PC, and Serial Monitor is running, everything works fine. Even if i comment out Serial.begin. I'm not using any I/O before setup() runs, and I've even moved object initialization to setup(). I've tried simulating the Serial.print-s with delay(), but it doesn't help.
The problematic button is neither the first, nor last to be measured. Everything runs in the loop() function.
I've thought of it being a memory problem, but avr-size reports 662 bytes for statically allocated memory(I'm not using new()), so i should be fine on an ATmega328P.
Has anyone come across something similar? Any help appreciated.