Okay i've been using the junXion interface to send signals from analog pin 0. I've just now written a basic script to multiplex. It works by connecting 8xIC4051 to 1xIC4051 to analog pin 0. Connecting digital pins 2/3/4 to each of the 8xIC4051 and digital pins 5/6/7 to the main IC4051. pretty basic but here it is:
int led = 13;
int r0 = 0;
int r1 = 0;
int r2 = 0;
int m0 = 0;
int m1 = 0;
int m2 = 0;
int row = 0;
int rowM = 0;
int count = 0;
int countF = 0;
int analogValue = 0;
int bin[] = {000,1,10,11,100,101,110,111};
int binM[] = {000,1,10,11,100,101,110,111};
void setup(){
pinMode(2, OUTPUT); // s0
pinMode(3, OUTPUT); // s1
pinMode(4, OUTPUT); // s2
pinMode(5, OUTPUT); // s3
pinMode(6, OUTPUT); // s4
pinMode(7, OUTPUT); // s5
digitalWrite(led, HIGH);
Serial.begin(115200);
}
void loop () {
int countB = 21;
for (countF=0; countF<=6; countF++){
rowM = binM[countF];
m0 = rowM & 0x01;
m1 = (rowM>>1) & 0x01;
m2 = (rowM>>2) & 0x01;
digitalWrite(5, m0);
digitalWrite(6, m1);
digitalWrite(7, m2);
for (count=0; count<=7; count++){
row = bin[count];
r0 = row & 0x01;
r1 = (row>>1) & 0x01;
r2 = (row>>2) & 0x01;
digitalWrite(2, r0);
digitalWrite(3, r1);
digitalWrite(4, r2);
//Serial.print(countF); //main multiplex ID
//Serial.print(count); //multiplex ID
Serial.print(countB);
countB++;
Serial.print(",");
analogValue = analogRead(0); //ID reading
Serial.print(analogValue);
Serial.println();
delay(200);
}
}
}
Anyway my problem is how do I integrate this with the junXion interface. Anyone that uses JunXion/Arduino will know about the sketch file it comes with (attached below).
http://www.easy-share.com/1904514728/junXion_Arduino.pde
I can't figure out how to add more inputs so I can send the multiplex readings into junXion. Anyone got any ideas?
Would be very much appreciated!