2010年8月17日火曜日

Card

Technical detail of my artwork


Arduino 1

/*
Name of Arduino COM4
Program for Art Work
Version 1.4
Huge 7 segment controller with Shift registor.
Made by Shotaro N 2010

note:
Somehow,you need Serial.print(); in a function of block();.
It does not do anything, but without having it, the program does not work properly.
Ver 1.1 added relay control and LEDcontrol
Ver 1.2 fixed a relay proglem
Ver 1.3 added a daisy chain pulse controller
Ver 1.4 change daisy chain controller from transistor to relay
*/

//reguler variable to store data
int c;
int rec1, rec2, rec3, rec4;
// error checking counter
int checkND=0;
//controller variables
long vTime=45000;
int amount7S =4;
//Shift Registor
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
int latchPin2 = 2;
int clockPin2 = 4;
int dataPin2 = 3;
int ledPin =13;
int relayPin =6;
int daisyChainPin = 7;

void setup()
{
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(latchPin2, OUTPUT);
pinMode(clockPin2, OUTPUT);
pinMode(dataPin2, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(relayPin, OUTPUT);
pinMode(daisyChainPin, OUTPUT);
digitalWrite(daisyChainPin, LOW);
delay(10);
digitalWrite(relayPin, LOW);
delay(10);
}

void loop(){
digitalWrite(relayPin, HIGH);
delay(10);
if(Serial.available()>0){
//reading validity of words
block1();
block2();
block3();
block4();
Serial.println("");
Serial.print("CheckND value");
Serial.println(checkND);
//to ignore words with EXtra
EXchecker();
Serial.print("CheckND value");
Serial.println(checkND);
//main checking process
if (checkND ==amount7S){
Serial.println("start light LEDs section");
digitalWrite(relayPin, LOW);
digitalWrite(daisyChainPin, HIGH);
delay(1);
Serial.print("Sending a pulse to the second Arduino");
Serial.print(".");
Serial.print(".");
Serial.println(".");
digitalWrite(ledPin, HIGH);
//main LED
digitalWrite(latchPin, LOW);
c = rec4;
process();
c = rec3;
process();
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin2, LOW);
c = rec2;
processSEC();
c = rec1;
processSEC();
digitalWrite(latchPin2, HIGH);
delay(vTime);
checkND = 0;
reset();
digitalWrite(ledPin, LOW);
digitalWrite(daisyChainPin, LOW);
digitalWrite(relayPin, HIGH);
delay(1);
}
//checkND = 0;
//reset();
}//main if end
//protection reset
checkND = 0;
reset();
}

//EDN OF VOID LOOP


//first block
void block1(){
rec1=Serial.read();
c = rec1;
Cprocess();//check prosecc
Serial.print("block1");
}
//second block
void block2(){
rec2=Serial.read();
c = rec2;
Cprocess();
Serial.print("block2");
}
//third block
void block3(){
rec3=Serial.read();
c = rec3;
Cprocess();
Serial.print("block3");
}
//Fourth block
void block4(){
rec4=Serial.read();
c = rec4;
Cprocess();
Serial.print("block4");
}

// checker
void Cprocess(){
if(c=='8'){
checkND = checkND + 1;
}
else if(c=='0'){
checkND = checkND + 1;
}
else if(c=='1'){
checkND = checkND + 1;
}
else if(c=='2'){
checkND = checkND + 1;
}
else if(c=='3'){
checkND = checkND + 1;
}
else if(c=='4'){
checkND = checkND + 1;
}
else if(c=='5'){
checkND = checkND + 1;
}
else if(c=='6'){
checkND = checkND + 1;
}
else if(c=='7'){
checkND = checkND + 1;
}
else if(c=='9'){
checkND = checkND + 1;
}
else{
}
}

//judgement & lighting
void process(){
if(c=='8'){
shiftOut(dataPin, clockPin, MSBFIRST, 254);
}
else if(c=='0'){
shiftOut(dataPin, clockPin, MSBFIRST, 250);
}
else if(c=='1'){
shiftOut(dataPin, clockPin, MSBFIRST, 96);
}
else if(c=='2'){
shiftOut(dataPin, clockPin, MSBFIRST, 220);
}
else if(c=='3'){
shiftOut(dataPin, clockPin, MSBFIRST, 244);
}
else if(c=='4'){
shiftOut(dataPin, clockPin, MSBFIRST, 102);
}
else if(c=='5'){
shiftOut(dataPin, clockPin, MSBFIRST, 182);
}
else if(c=='6'){
shiftOut(dataPin, clockPin, MSBFIRST, 62);
}
else if(c=='7'){
shiftOut(dataPin, clockPin, MSBFIRST, 226);
}
else if(c=='9'){
shiftOut(dataPin, clockPin, MSBFIRST, 230);
}
}

//judgement & lighting
void processSEC(){
if(c=='8'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 254);
}
else if(c=='0'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 250);
}
else if(c=='1'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 96);
}
else if(c=='2'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 220);
}
else if(c=='3'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 244);
}
else if(c=='4'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 102);
}
else if(c=='5'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 182);
}
else if(c=='6'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 62);
}
else if(c=='7'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 226);
}
else if(c=='9'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 230);
}
}


// EXchecker. protect system from invalid value
void EXchecker(){
if(Serial.available()>0){
int reader = Serial.read();
if(reader == -1){
}
else{
checkND = checkND +10;// protect from hack
}
}
}


void reset(){
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin2, LOW);
shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
digitalWrite(latchPin2, HIGH);
}




Arduino 2

  


/*
Program for second Arduino
Ver 1.3

Serial in Watcher "1" got data from daisy chain
Serial in Watcher "2" got data from ultrasonic range finder
Serial in Watcher "3" got data from motion sensor

Ver 1.0 basic
Ver 1.1 error correction about values
added while loop to fix communication Arduino and Isadora
Ver 1.2 fixed motion sensor value
Ver 1.3 fixed problem especially reset commend
Ver 1.4 take out motion sensor and reduce pressure to a computer
*/

//regular variable
//int alarmValue = 1;
int val=0;
int defaultLength=330; // max value of sonic range finder

//analog pins
//int alarmPin = 1;//motion sensor
int daisyChainPin = 0;
//digital pins
int ledPin = 13;
const int pingPin = 7;//Ultrasonic

//loop speed
int delayTime = 200;


void setup () {
Serial.begin (9600);
pinMode(ledPin, OUTPUT);
//pinMode(alarmPin, INPUT);
//delay (2000); //wait for a motion sensor to be ready to go
digitalWrite(ledPin, LOW);
}

void loop ()
{
val = analogRead(daisyChainPin);
if (val>100){

//turn on LED while the second arduino got pulse from the first arduino
digitalWrite(ledPin, HIGH);


val =1;//to activate Isadora
Serial.print(1,DEC);
Serial.print (val, DEC);
Serial.println();
val = analogRead(daisyChainPin);
while(val>100){
/*
for ultrasonic range finder. source from
http://www.arduino.cc/en/Tutorial/Ping

created 3 Nov 2008
by David A. Mellis
modified 30 Jun 2009
by Tom Igoe
*/

long duration, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
cm = microsecondsToCentimeters(duration);

//ignore crazy value

if(cm>330){
cm = 330;
}

//send this value to use for something

Serial.print(2,DEC);
Serial.print (cm, DEC);
Serial.println();


//motion sensor
//based on http://www.eathertons.com/blog/?p=73
//Shotaro fixed the code little bit
/*
alarmValue = analogRead(alarmPin);
if (alarmValue < 100){
alarmValue =1;
sendPulse();
}
else{
}
*/
delay(delayTime);

val = analogRead(daisyChainPin);//Value for While
}//While loop
digitalWrite(ledPin, LOW);
dataReset();
}
}
//END of void loop




//culculation from microsecond to length
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}



/*
//send a data from motion sensor to Isadora
//This value will control "counter" of Isadora
void sendPulse() {
Serial.print(3,DEC);
Serial.print (alarmValue, DEC);
Serial.println();
}
*/

void dataReset(){
Serial.print(1,DEC);
Serial.print (0, DEC);
Serial.println();
Serial.print(2,DEC);
Serial.print (defaultLength, DEC);
Serial.println();
//Serial.print(3,DEC);
//Serial.print (0, DEC);
//Serial.println();
}



Arduino 3



int alarmPin = 1;//motion sensor
int alarmValue = 1;
int delayTime = 200;


void setup(){
Serial.begin(9600);
pinMode(alarmPin, INPUT);
delay (2000); //wait for a motion sensor to be ready to go
}
void loop(){
alarmValue = analogRead(alarmPin);
if (alarmValue < 100){
//alarmValue =1;
sendPulse();
}
else{
}
delay(delayTime);
}

//send a data from motion sensor to Isadora
//This value will control "counter" of Isadora
void sendPulse() {
Serial.print(3,DEC);
Serial.print (alarmValue, DEC);
Serial.println();
}

2010年8月9日月曜日

program for the second Arduino(Isadora controller)

This program will light led when the second Arduino got a pulse from the first Arduino, and 

send data of sensors to Isadora

/*

Program for second Arduino
Ver 1.0 unchecked

Serial in Watcher "1" got data from daisy chain
Serial in Watcher "2" got data from ultrasonic range finder
Serial in Watcher "3" got data from motion sensor
*/

//regular variable
int alarmValue = 1;
int val=0;

//analog pins
int alarmPin = 1;
int daisyChainPin = 0;
//digital pins
int ledPin = 13;
const int pingPin = 7;


void setup () {
Serial.begin (9600);
pinMode(ledPin, OUTPUT);
pinMode(alarmPin, INPUT);
delay (2000); //wait for a motion sensor to be ready to go
digitalWrite(ledPin, LOW);
}

void loop ()
{
val = analogRead(daisyChainPin);
if (val>100){

//turn on LED while the second arduino got pulse from the first arduino
digitalWrite(ledPin, HIGH);


val =1;//to activate Isadora
Serial.print(1,DEC);
Serial.print (val, DEC);
Serial.println();

/*
for ultrasonic range finder. source from
http://www.arduino.cc/en/Tutorial/Ping

created 3 Nov 2008
by David A. Mellis
modified 30 Jun 2009
by Tom Igoe
*/
long duration, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
cm = microsecondsToCentimeters(duration);
//send this value to use for something
Serial.print(2,DEC);
Serial.print (cm, DEC);
Serial.println();

//motion sensor
//based on http://www.eathertons.com/blog/?p=73
//Shotaro fixed the code little bit

alarmValue = analogRead(alarmPin);
if (alarmValue < 100)
{
alarmValue =1;
sendPulse();
}
delay(100);
digitalWrite(ledPin, LOW);
}
}
//END of void loop




//culculation from microsecond to length
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}




//send a data from motion sensor to Isadora
//This value will control "counter" of Isadora
void sendPulse() {
Serial.print(3,DEC);
Serial.print (alarmValue, DEC);
Serial.println();
}
}

motion sensor information

Since we have two different motion sensor this link will help to use the motion sensor which I did not make tutorial.

Check below link to see the first motion sensor tutorial.

http://art-research2010summer.blogspot.com/2010/06/sensor-motion-sensor.html


http://www.eathertons.com/blog/?p=73



The most different point of these two motion sensor is that the colors of the wire are different so that we need to change the connection of the wire and the motion sensor that is talked in the link require a resistor.


I think it is a good idea to reduce the delay  time in a program that was introduced in the link so that the motion sensor works more ideally.  Also I preferred to use a more higher resistor that the resistor that was used in a tutorial so that you can get more good data from the motion sensor. 

 

2010年8月8日日曜日

Isadora setup

Serial In watcher will control everything, so that Arduino can control everything.

Somehow Isadora's picture player does not work properly. Even I send a value 0 to turn off visibility, it does not work. Only wave generator can controll on and off.

 Also "Gate" does not work for picture player.

Arduino Daisy Chain 2


Program for Arduino Daisy Chain

This program is specifically designed to communicate with Isadora.

You can use this program as a switch in Isadora.



Program for a host Arduino

/*

this program is just send on and off signal to client Arduino every 2 second

*/

int signalPin=3;
void setup(){
pinMode(signalPin, OUTPUT);

digitalWrite(signalPin, LOW);
}
void loop(){
 
digitalWrite(signalPin, HIGH);
delay(2000);
digitalWrite(signalPin, LOW);
delay(2000);
}


Program for a Client

int ReadingPin = 0;
int val;
void setup(){
Serial.begin(9600);

}
void loop(){
val = analogRead(ReadingPin);

/*

with this "if" commend, Arduino does not send any data to Isadora when an analog pin receive nothing.

*/
  if (val>100){
  val=1;//you can change value to anything you want 
Serial.print(1,DEC);
Serial.print (val, DEC);
Serial.println();
delay(50);
}
}






Projector test











2010年8月6日金曜日

Program for LED controller Ver 1.0(Updated from Ver 0.11 and checked)

/*
Program for Art Work
Version 1.0
Huge 7 segment controller with Shift registor.
Made by Shotaro N 2010

note:
Somehow,you need Serial.print(); in a function of block();.
It does not do anything, but without having it, the program does not work properly.
*/

//reguler variable to store data
int c;
int rec1, rec2, rec3, rec4;
// error checking counter
int checkND=0;
//controller variables
int vTime=25000;
int amount7S =4;
//Shift Registor
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
int latchPin2 = 2;
int clockPin2 = 4;
int dataPin2 = 3;


void setup()
{
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(latchPin2, OUTPUT);
pinMode(clockPin2, OUTPUT);
pinMode(dataPin2, OUTPUT);
}
void loop(){
if(Serial.available()>0){
//reading validity of words
block1();
block2();
block3();
block4();
Serial.print("this is first");
Serial.println(checkND);
//to ignore words with EXtra
EXchecker();
Serial.print("this is second");
Serial.println(checkND);
//main checking process
if (checkND ==amount7S){
Serial.println("start light LEDs");
//main LED
digitalWrite(latchPin, LOW);
c = rec4;
process();
c = rec3;
process();
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin2, LOW);
c = rec2;
processSEC();
c = rec1;
processSEC();
digitalWrite(latchPin2, HIGH);
delay(vTime);
checkND = 0;
reset();
}
//checkND = 0;
//reset();
}//main if end
//protection reset
checkND = 0;
reset();
}

//EDN OF VOID LOOP


//first block
void block1(){
rec1=Serial.read();
c = rec1;
Cprocess();//check prosecc
Serial.print("block1");
}
//second block
void block2(){
rec2=Serial.read();
c = rec2;
Cprocess();
Serial.print("block2");
}
//third block
void block3(){
rec3=Serial.read();
c = rec3;
Cprocess();
Serial.print("block3");
}
//Fourth block
void block4(){
rec4=Serial.read();
c = rec4;
Cprocess();
Serial.print("block4");
}

// checker
void Cprocess(){
if(c=='8'){
checkND = checkND + 1;
}
else if(c=='0'){
checkND = checkND + 1;
}
else if(c=='1'){
checkND = checkND + 1;
}
else if(c=='2'){
checkND = checkND + 1;
}
else if(c=='3'){
checkND = checkND + 1;
}
else if(c=='4'){
checkND = checkND + 1;
}
else if(c=='5'){
checkND = checkND + 1;
}
else if(c=='6'){
checkND = checkND + 1;
}
else if(c=='7'){
checkND = checkND + 1;
}
else if(c=='9'){
checkND = checkND + 1;
}
else{
}
}

//judgement & lighting
void process(){
if(c=='8'){
shiftOut(dataPin, clockPin, MSBFIRST, 254);
}
else if(c=='0'){
shiftOut(dataPin, clockPin, MSBFIRST, 250);
}
else if(c=='1'){
shiftOut(dataPin, clockPin, MSBFIRST, 96);
}
else if(c=='2'){
shiftOut(dataPin, clockPin, MSBFIRST, 220);
}
else if(c=='3'){
shiftOut(dataPin, clockPin, MSBFIRST, 244);
}
else if(c=='4'){
shiftOut(dataPin, clockPin, MSBFIRST, 102);
}
else if(c=='5'){
shiftOut(dataPin, clockPin, MSBFIRST, 182);
}
else if(c=='6'){
shiftOut(dataPin, clockPin, MSBFIRST, 62);
}
else if(c=='7'){
shiftOut(dataPin, clockPin, MSBFIRST, 226);
}
else if(c=='9'){
shiftOut(dataPin, clockPin, MSBFIRST, 230);
}
}
//judgement & lighting
void processSEC(){
if(c=='8'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 254);
}
else if(c=='0'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 250);
}
else if(c=='1'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 96);
}
else if(c=='2'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 220);
}
else if(c=='3'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 244);
}
else if(c=='4'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 102);
}
else if(c=='5'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 182);
}
else if(c=='6'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 62);
}
else if(c=='7'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 226);
}
else if(c=='9'){
shiftOut(dataPin2, clockPin2, MSBFIRST, 230);
}
}


// EXchecker. protect system from invalid value
void EXchecker(){
if(Serial.available()>0){
int reader = Serial.read();
if(reader == -1){
}
else{
checkND = checkND +10;// protect from hack
}
}
}


void reset(){
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin2, LOW);
shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
shiftOut(dataPin2, clockPin2, MSBFIRST, 0);
digitalWrite(latchPin2, HIGH);
}

fixed a troble of a LEDs controller




LED controller is made by 4 8-bit shift resistors, 28 transistors and 28 resistors.





2010年8月2日月曜日