I am building an arcade joystick with the Arduino Due. Right now I get random input from touching acrylic case I have the buttons mounted in. I'm pretty sure the acrylic case isn't conductive. Attached is my wiring diagram. The weird thing is that I only get random input from the buttons and not the joystick.
#define BUTTONS_MAX 18
#define BUTTONS_PININ (const int []) { 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 25, 24, 23, 22 }
void setup() {
Serial.begin(9600);
for (int i = 0; i < BUTTONS_MAX; i++)
pinMode(BUTTONS_PININ[i], INPUT_PULLUP);
}
void loop() {
for (int i = 0; i < BUTTONS_MAX; i++)
if (digitalRead(BUTTONS_PININ[i]) == LOW)
Serial.println(BUTTONS_PININ[i]);
}
I know you set INPUT_PULLUP for those pins but the pull up resistor on the processor isn't strong - perhaps 100k. You're probably best off using stronger pull up resistors, say 10k. You could get away with as low as 1k for the pull up resistor but that would allow 3.3ma to flow when you push the button. Try 10k - for each button individually - and see how that works.
Acrylic isn't conductive really but it can build up static charge and so you can you. Touching the plastic case could release some static electricity even if you don't feel it. That's not particularly good for the processor. A lot of times people like to use opto-isolation when they're taking input from things that could come in contact with people and nasty transient voltages. If you do end up blowing up the Due then suspect static electricity and use opto-isolation. Otherwise just try the stronger pull up resistors.