below is code for the different installations.
the kube
controlling a 1x1x1 grid of fluorescent light tubes with an arduino microcontroller. the fluorescent light tubes gets power from a supply box built by nicolas padfield of illutron.
the electronics are designed by ucapps.de, basically 4 serial registers 74HC595, which means that this setup in theory could be scaled to any amount of outputs / fluorescent light tubes wanted.
/* KUBE made for the exhibit STANDING ON THE SHOULDERS OF GIANTS by jacob sikker remin and marcin ignac AKA vorg https://giantshouldersherewecome.wordpress.com copyleft 2009 */ int latchPin = 12; int clockPin = 11; int dataPin = 10; int switchPin = 2; boolean on = true; int counter = 0; int potPin = 0; int ledPin = 13; boolean ledState = false; // delay int del = 500; //print status to serial port every printTime ms int printTime = 400; long lastTime = millis(); // storing 16bits in 2 bytes byte data1 = 0; byte data2 = 0; // vorg variables static const int A = 0; static const int B = 1; static const int C = 2; static const int D = 3; static const int E = 4; static const int F = 5; static const int G = 6; static const int H = 7; boolean dataBool[16] = { false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; //to which points I can go from current point in x,y,z direction int transitionTable[8][3] = { {B, D, E} , //A {A, C, F} , //B {D, B, G} , //C {C, A, H} , //D {F, H, A} , //E {E, G, B} , //F {H, F, C} , //G {G, E, D} //H }; //edges between points int edges[12][2] = { {A, B} , {B, C} , {C, D} , {D, A} , {A, E} , {B, F} , {C, G} , {D, H} , {E, F} , {F, G} , {G, H} , {H, E} , }; //whitch edges are highlighted (lighted up) int highlighted[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; //translation array compensating for wiring mess int translate[] = { 3, 8, 6, 4, 9, 2, 1, 5, 11, 12, 10, 14 }; int numLights = 12; int val; int currentPoint = 0; int previousPoint = 0; int previousPreviousPoint = 0; int frame = 0; void setup() { Serial.begin(9600); pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(ledPin, OUTPUT); pinMode(switchPin, INPUT); } void loop() { //int delayTime = analogRead(potPin)*5; int delayTime = 1000; //timer click if (lastTime+delayTime < millis()) { if (digitalRead(switchPin)) { // all on/off if (on) { for (int i=0;i<16;i++){ dataBool[i]=true; } } else { for (int i=0;i1200 && on==true) { on = false; counter = 0; } if (counter>300 && on==false) { on = true; counter = 0; } } else { // snake time! animate(); } ledState = !ledState; digitalWrite(ledPin, ledState); printValues(); lastTime = millis(); compileBytes(); } sendData(data1, data2); } void compileBytes () { for (int i = 0; i<8; i++) { bitWrite(data1, i, dataBool[i]); } for (int i = 8; i<16; i++) { bitWrite(data2, i-8, dataBool[i]); } } void printValues() { Serial.print("data1: "); for (int i = 0; i<8; i++) { if (dataBool[i]) { Serial.print("1"); } else { Serial.print("0"); } } int dataInt1 = data1; Serial.print(" in decimal: "); Serial.print(dataInt1); Serial.print(" "); Serial.print("data2: "); for (int i = 8; i 50); for(int i=0; i<3; i++) { if (transitionTable[currentPoint][i] != previousPoint) { if (dontChooseTheFirstFound) { dontChooseTheFirstFound = false; } else { nextPoint = transitionTable[currentPoint][i]; break; } } } previousPreviousPoint = previousPoint; previousPoint = currentPoint; currentPoint = nextPoint; //reset state to zero for(int i=0; i<numLights; i++) { highlighted[i] = 0; dataBool[translate[i]] = false; } int newHighlightedEdge = findEdgeFor(previousPoint, currentPoint); if (newHighlightedEdge != -1) { highlighted[newHighlightedEdge] = 1; dataBool[translate[newHighlightedEdge]] = true; } int prevHighlightedEdge = findEdgeFor(previousPreviousPoint, previousPoint); if (prevHighlightedEdge != -1) { highlighted[prevHighlightedEdge] = 1; dataBool[translate[prevHighlightedEdge]] = true; } } int findEdgeFor(int p1, int p2) { for(int i=0; i<numLights; i++) { if ((edges[i][0] == p1) && (edges[i][1] == p2) || (edges[i][0] == p2) && (edges[i][1] == p1)) { return i; } } //println("No edge found for " + p1 + " " + p2); return -1; }
_______________________________________________________
devine pixel
arduino microcontroller hooked up to 1 PING))) distance sensor, controlling 2 relays each controlling 5 fluorescent light tubes,
// devine pixel // jacob sikker remin // https://giantshouldersherewecome.wordpress.com // copyleft 2009 int numOfRelays = 2; int relay[2] = { 2, 8}; int potPin = 0; int pingPin = 3; int sensLed = 12; int buttonPin = 13; boolean nightMode = false; void setup() { for (int i =0; i<numOfRelays; i++) { pinMode(relay[i], OUTPUT); } Serial.begin(9600); pinMode(sensLed, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { if (digitalRead(buttonPin) == LOW) { digitalWrite(relay[0],LOW); digitalWrite(relay[1],LOW); nightMode = true; } else { nightMode = false; } if (nightMode) { int ran = random(1200); Serial.print("ran: "); Serial.println(ran); if (ran == 1) { digitalWrite(relay[0],HIGH); delay(7000); digitalWrite(relay[1],HIGH); delay(2000); digitalWrite(relay[0],LOW); delay(5000); digitalWrite(relay[1],LOW); } delay(100); } else { long duration, cm; // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. // We give a short LOW pulse beforehand to ensure a clean HIGH pulse. pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); // The same pin is used to read the signal from the PING))): a HIGH // pulse whose duration is the time (in microseconds) from the sending // of the ping to the reception of its echo off of an object. pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); // convert the time into a distance cm = microsecondsToCentimeters(duration); Serial.print(cm); Serial.print("cm"); delay(100); int threshold = analogRead(potPin)/4; Serial.print("\t"); Serial.print("threshold: "); Serial.println(threshold); if (cm < threshold) { digitalWrite(sensLed, HIGH); digitalWrite(relay[0], HIGH); digitalWrite(relay[1], HIGH); } else { digitalWrite(sensLed, LOW); digitalWrite(relay[0], LOW); digitalWrite(relay[1], LOW); } /* int pause = analogRead(potPin)*10; digitalWrite(2, HIGH); delay(pause); pause = analogRead(potPin)*10; digitalWrite(8, HIGH); delay(pause); pause = analogRead(potPin)*10; digitalWrite(2, LOW); delay(pause); pause = analogRead(potPin)*10; digitalWrite(8, LOW); delay(pause); */ } } long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. return microseconds / 29 / 2; }
_______________________________________________________
video shaker
see blog post for description of installation
// read 3 PING))) sensors and create square noise if something there // jacob sikker remin // https://giantshouldersherewecome.wordpress.com // copyleft 2009 int pingPin[3] = { 4, 7, 8}; int ledPin[3] = { 9, 10, 11}; int potPin = 0; long lastTime = millis(); int updateTime = 500; long cm[3]; int threshold; long lastPing = millis(); int updatePing = 50; int speakerPin = 6; boolean someoneThere[3] = { false, false, false}; void setup() { Serial.begin(9600); for (int i = 0; i<3; i++) { pinMode(ledPin[i], OUTPUT); } pinMode(speakerPin, OUTPUT); } void loop() { if (lastPing + updatePing < millis()) { lastPing = millis(); for (int i = 0; i threshold) { digitalWrite(ledPin[i], LOW); someoneThere[i] = false; } else { digitalWrite(ledPin[i], HIGH); someoneThere[i] = true; } } } for (int i = 0; i lastTime + updateTime) { printStatus(); } } void simpleSquareWave (int v1, int v2) { digitalWrite(speakerPin, HIGH); delayMicroseconds(v1); digitalWrite(speakerPin, LOW); delayMicroseconds(v2); } void printStatus (){ Serial.print("threshold: "); Serial.print(threshold); Serial.print("\t"); for (int i = 0; i < 3; i++) { Serial.print(i); Serial.print(": "); Serial.print(cm[i]); Serial.print("\t"); } Serial.println(); } long pingRead (int thePing) { // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. // We give a short LOW pulse beforehand to ensure a clean HIGH pulse. pinMode(pingPin[thePing], OUTPUT); digitalWrite(pingPin[thePing], LOW); delayMicroseconds(2); digitalWrite(pingPin[thePing], HIGH); delayMicroseconds(5); digitalWrite(pingPin[thePing], LOW); // The same pin is used to read the signal from the PING))): a HIGH // pulse whose duration is the time (in microseconds) from the sending // of the ping to the reception of its echo off of an object. pinMode(pingPin[thePing], INPUT); long duration = pulseIn(pingPin[thePing], HIGH); // convert the time into a distance return microsecondsToCentimeters(duration); } long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. return microseconds / 29 / 2; }
3 Trackbacks/Pingbacks
[…] on the shoulders of giants development blog for the SOTSOG exhibit aboutcode « […]
[…] on the shoulders of giants development blog for the SOTSOG exhibit aboutcode « pictures now on flickr the kube […]
[…] on the shoulders of giants development blog for the SOTSOG exhibit aboutcode « busy busy media mess […]