Tuesday, December 11, 2007

Final | coding and mapping

Our next step should be checking which switch connect to which pin. Arduino got some values from the switches (from value 0 to value 63), but we could not know that they are from which switches. So we started checking through each switch and matched the value and the switch. Actually, for some reasons, our first mapping did not work, so we did twice. It was really time consuming. But after this work, we faced another issue. We should know two things - the positions of the switches and switches' status, turn on or turn off. So we started rewriting our code. We tried to say that an array is saying the positions of switches and if this array's value is 0 (or 1) that means switches are off(or on). But we did not get it with this logic. The logic was perfect but it was hard to translate to the code for us. So, we went back to the start point and restarted. That point, I got an idea. We have 64 arraies and they can have two valuses which are 0 and 1. For example, if position #10 switch is on, val[9] will have 1. Instead of an arduino reads array positions and values (0 or 1) saperately, what if an arduino reads one value at once? I thought I could make it with a simple math.

if((channelNum+1) * val[channelNum] == channelNum+1){
Serial.print(((64+(channelNum+1))),BYTE);
Serial.print("\t");
//switch on
}

if( (channelNum+1) + val[channelNum] == channelNum+1){
Serial.print((channelNum+1),BYTE);
Serial.print("\t");
//switch off

So if switches are on, an arduino will send switch number(1-64) and if they are off , it will send switch number+64 to processing. Finally, processing could get unique values accoding to the switch's status so it could trigger unique images.

Final | wiring with 4 multiplexers

The tray was completed and Estee kept writing processing code for 64 switches. We almost ready to use 4 multiplexers. So I started building a circuit with them. Todd said it is better to make resistors fit on the breadboard, we should use pins under the resistors so I put resistors little bit higher. And I put all wires and connected the breadboard to the arduino. It was really hard to maintain all wires on the breadboard because wires were hooked up so easily. If I have a chance to do it again, It would be better to solder all wires on the perfboard.



Final | construction - cubes

We ordered 96 pieces of plastic glasses, glued them except the top ones, contained new bits and glued top ones again. Finally there were beautiful 16 cubes! And as we tested, we attached copper tapes on one corner of the bottom of the cube like this picture. This tape was going to connect two wires - power and ground- on the tray like a switch. Actually, we expected really good connections with it but it did not work well. Because the cube's surface was so flat and hard, so if two wire, power and ground, on the tray were not even, this connector could not touch both of them in other words it could not close a switch.


We needed more cushioned or more flexable connectors. After trying many different ways, we decided to attach two wires on the copper tape as a cross. Because it was an easest way to fix this problem, but if we had more time, it might be better to look for a neater way. But it helped connections pretty well. Here is a picture of a new connector.

Final | construction - a tray

First of all, Estee cut the wood as a suit size and I started making this tray with a lot of wires. I made 256 hole on the tray, 4 holes for each switch, and inserted a wire from the backside of the tray to the frontside, banded it and pushed it from the frontside to backside. I repeated it 128 times because each switch needed 2 wires. My fingurs were almost dead. It was really painful. Fianlly, I got 64 beautiful switches like a picture.

Here is one more issue. Initially we used small crosses to divide each position for each cube looked like a below picture, but it did not help users notice where they could place cubes on the tray. In order to guide how to place cubes, we needed more certain dividers, so I got rid of all old ones and made new ones like a grid. And it worked well!


Frontside of the tray was neat but on the backside, all wires were all the mess. Even though I used different colors to distingush which wires go to which positions, it was really hard to control all wires.

Final | changing bits

Even though we kept making our bits, it was still not enough to fill all cubes and too much work. And we thought spending more time writing codes and constructions was more important in this point , so we started looking for bits that replaced original ones. Finally, Seanita got punched paper bits from the copy center, and these papers sticked each other so they were 3D bits, not a single paper and more looked like bits. And when we shaked the cube with our new bits they made an interesting sound, also they had various color on them. Above all, people really liked new bits and playing with them so we decided to use them.

These are our original white bits. It was good to project image on them, but it would take long time.



These are our new bits. More colorful and more playful.

Final | a code for a single multiplexer

We also got a code for a sing mux from Chris, and this code was wotking perfectly. Here is a code.

int val[16];

//variables in this code have been changed from their original value of Int to byte.
int a= 3; // SELECT PIN A0 GOING INTO PIN 2
int b= 4; // SELECT PIN A1 GOING INTO PIN 3
int c= 5; // SELECT PIN A2 GOING INTO PIN 4
int d= 6; // SELECT PIN A3 GOING INTO PIN 5

int analog0 = 0;

void setup() {
Serial.begin(9600);
pinMode(analog0, INPUT);
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
}

void loop() {
for (int channelNum = 0; channelNum < style="font-style: italic; color: rgb(51, 102, 102);">

// determine the four address pin values from the channelNum:

// mask off bit 0:
int pinOne = 1 & channelNum;
// shift value 1 bit to the right, and mask all but bit 0:
int pinTwo = 1 & (channelNum >> 1) ;
// shift value 2 bits to the right, and mask all but bit 0:
int pinThree = 1 & (channelNum >> 2);
// shift value 3 bits to the right, and mask all but bit 0:
int pinFour = 1 & (channelNum >> 3);

// set the address pins:
digitalWrite(a,pinOne);
digitalWrite(b,pinTwo);
digitalWrite(c,pinThree);
digitalWrite(d,pinFour);

// read the analog input and store it in the value array:
val[channelNum] = analogRead(analog0);

// print the values as a single tab-separated line:
Serial.print(val[channelNum], DEC);
Serial.print("\t");
}
// print a carriage return at the end of each read of the mux:
Serial.println();

}

Final | testing with single a multiplexer - building

After getting a satisfactory result from a prototype, we tried a single multiplexer(MC14067BCP MUX) instead of two arduinos with 16 input pins. Fortunately, Chris already tried a single multiplexer so he let us know how to build a circuit board and a code for it. His guide was really helpful. (Thanks Chris!) We needed 10k resistors between every input pin and every ground which were 16 . It was really cool that we used only an anolog input and 4 address pins on an arduino but a multiplexer could send 16 different values with a binary such as 0000,0001,0010, 0100, 1000, 1100, 0110, 0011, 1001, .... 1111. After building a circuit, we connected all wires from a prototype to a breadboad. We were almost ready to try a multiplexer.