Arduino using conductive paint

Hello everyone, so Ive been stuck on this for quite sometime.

I have a allegator clip on the conductive paint going into pin #2. I have a ground from the arduino going to a ground. When I press down on the paint it makes a solid "off" but the moment I let go of the aint it goes berzerk on the debug window showing:

on
on
off
off

The objective is when I press my finger on the paint I want it to activate a sound but when I take my fingers off it goes haywire. heres the following code I am using:

#include "SD.h"
#define SD_ChipSelectPin 4
#include "TMRpcm.h"
#include "SPI.h"

TMRpcm tmrpcm;
const int buttonPin = 2;     // the number of the pushbutton pin

// variables will change:
int buttonState = 0;   

void setup() {
pinMode(buttonPin, INPUT);
tmrpcm.speakerPin = 9;
Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}
}


void loop() {
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {

    Serial.println("button on");
    tmrpcm.stopPlayback ();
  } 
    else if (buttonState == LOW) {

    Serial.println("button OFF");
    tmrpcm.setVolume(5);
    tmrpcm.play ("3.wav");
}
}

Change this:
pinMode(buttonPin, INPUT);

to:
pinMode(buttonPin, INPUT_PULLUP);

You have discovered floating input pins cause all kinds of problems!

Paul

If you do use INPUT_PULLUP your logic will be switched, i.e. unpressed is HIGH and pressed is LOW.

It is likely that simply touching the conductive paint going to a pin will not be sufficient to pull it low. Your body is not as good a conductor as a wire with alligator clips and one end of you is not connected to the Arduino ground pin. Touch control is generally done with a library. For analog input pins there is "ADCTouch" and "ADCTouchSensor" and "AnalogTouch". For digital pins there is "CapacitiveSensor". Use Tools->Manage Libraries... to install one or more of them.