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");
}
}