Hey guys, so for my last semester studying Art X at the University of GA I tackled the task of making an interactive projection screen for my performance work. I succeeded in implementing a fairly accurate single-touch version of it back in December:
http://www.amanamun.com/blog/?p=24
When you press a place where a row and a column cross, the voltage of the column (determined by the resistor sitting at the top connecting it to the 5v power source) is fed to the analog input the row runs into. For some reason, however, when I press in a given position multiple analog inputs receive values. I've tried adding in delays between the different analogRead() calls and even tried the:
analogRead(row);
delay(10);
rowVal = analogRead(row);
delay(10);
trick but it doesn't seem to solve the problem. Originally my best guess was that my pulldown resistors ( originally 150 ohms ) we're the wrong value and that the voltage was getting to the other inputs via the ground wire, but I pulled off the pulldown resistors and still was able to replicate how a single voltage fed to one analog input would affect all the other analog inputs. I read somewhere on this board that the analog inputs are actually a single multiplexed input, are there any multiplexing tricks I can use to prevent this issue? What are my options to isolate the inputs so I can make this solid and multitouch for each row?
I'm also considering attaching all the rows straight to ground and using the onboard pullup resistors. Is this a bad idea? Can the excess voltage leak to the other input rows via the groundwire like I was concerned about?
I understand that while the scale is large this is a very basic circuit, and there may some very fundamental things I still don't understand about electrical engineering. I would really appreciate some direction asap.
Here's the most recent version of it's arduino code:
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include "OSCClass.h"
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte localIP[] = { 169, 254, 229, 100 };
byte remoteIP[] = { 169, 254, 229, 56 };
unsigned int localPort = 7040; // local port to listen on
unsigned int remotePort = 7050; // holds received packet's originating port
char *topAddress = "/arduino";
char *subAddress[2] = { "/analog", "/digital" };
OSCMessage recMessage;
OSCMessage sendMessage;
OSCClass osc(&recMessage);
long quiltState[128];
long runningAvgs[16];
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac, localIP);
osc.begin(localPort);
// for debugging
Serial.begin(19200);
enableInputs();
pullUp();
// clear osc buffer
osc.flush();
// configure outgoing osc
sendMessage.setIp(remoteIP);
sendMessage.setPort(remotePort);
sendMessage.setTopAddress(topAddress);
sendMessage.setSubAddress(subAddress[0]);
for( int i = 0; i < 128; i++) {
quiltState[i] = 0;
}
for( int i = 0; i < 16; i++) {
runningAvgs[i] = 0;
}
}
void loop() {
for( int i = 0; i < 16; i++) {
//analogRead(i);
//delay(10);
quiltState[i*8] = quiltState[i*7];
quiltState[i*7] = quiltState[i*6];
quiltState[i*6] = quiltState[i*5];
quiltState[i*5] = quiltState[i*4];
quiltState[i*4] = quiltState[i*3];
quiltState[i*3] = quiltState[i*2];
quiltState[i*2] = quiltState[i];
quiltState[i] = long(analogRead(i));
runningAvgs[i] = (quiltState[i] + quiltState[i*2] + quiltState[i*3] + quiltState[i*4] + quiltState[i*5] + quiltState[i*6] + quiltState[i*7] + quiltState[i*4] ) / 8;
//delay(10);
//long row = long(i);
//sendMessage.setArgs( "ii", &row, &quiltState[i] );
//osc.sendOsc(&sendMessage);
/**
Serial.print(i);
Serial.print(": ");
Serial.print(quiltState[i]);
Serial.print(" ");
**/
}
//Serial.println("");
sendMessage.setArgs( "iiiiiiiiiiiiiiii", &runningAvgs[0], &runningAvgs[1], &runningAvgs[2], &runningAvgs[3], &runningAvgs[4], &runningAvgs[5], &runningAvgs[6], &runningAvgs[7], &runningAvgs[8], &runningAvgs[9], &runningAvgs[10], &runningAvgs[11], &runningAvgs[12], &runningAvgs[13], &runningAvgs[14], &runningAvgs[15]);
osc.sendOsc(&sendMessage);
//delay(10);
}
void enableInputs() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);
pinMode(A7, INPUT);
pinMode(A8, INPUT);
pinMode(A9, INPUT);
pinMode(A10, INPUT);
pinMode(A11, INPUT);
pinMode(A12, INPUT);
pinMode(A13, INPUT);
pinMode(A14, INPUT);
pinMode(A15, INPUT);
}
void pullUp() {
digitalWrite(A0, HIGH);
digitalWrite(A1, HIGH);
digitalWrite(A2, HIGH);
digitalWrite(A3, HIGH);
digitalWrite(A4, HIGH);
digitalWrite(A5, HIGH);
digitalWrite(A6, HIGH);
digitalWrite(A7, HIGH);
digitalWrite(A8, HIGH);
digitalWrite(A9, HIGH);
digitalWrite(A10, HIGH);
digitalWrite(A11, HIGH);
digitalWrite(A12, HIGH);
digitalWrite(A13, HIGH);
digitalWrite(A14, HIGH);
digitalWrite(A15, HIGH);
}