■会期:2014年1月21日(火)-25日(土)
[23日(木)
西山修平(映像)
韓成南(映像+センサ+Webカメラ)
関根麻郎(映像+平面)
木下毅人(アナログシンセサイザー、ライブパフォーマンス:1/23
吉田きり(映像+Webカメラ+サウンド)
■会場:GALLERY OBJECTIVE CORRELATIVE(校舎1F)【地図】
■開場時間:11:00-17:00
■入場無料
//8x8の二次元配列を用意
byte matrix[8][8];
void setup(){
//出力ピンの設定、すべてオフにする
for(int i=2;i<=17;i++){
pinMode(i,OUTPUT);
digitalWrite(i,LOW);
}
//シリアル通信開始
Serial.begin(9600);
}
void loop(){
//シリアル通信(64個分のデータ)
if(Serial.available()>63){
for(int k=0;k<8;k++){
for(int l=0;l<8;l++){
//読み込んだ値を配列に代入
matrix[k][l]=Serial.read();
}
}
}
//各LEDの点灯制御
for(int i=2;i<=9;i++){
//列の点灯
digitalWrite(i,HIGH); //極性が逆の場合HIGHをLOW
for(int j=10;j<=17;j++){
//行の点灯
digitalWrite(j,LOW); //極性が逆の場合LOWをHIGH
//行の点灯継続時間
delayMicroseconds(1+matrix[i-2][j-10]);
//行の消灯
digitalWrite(j,HIGH); //極性が逆の場合HIGHをLOW
//行の消灯継続時間
delayMicroseconds(256-matrix[i-2][j-10]);
}
//列の消灯
digitalWrite(i,LOW); //極性が逆の場合LOWをHIGH
} }
マトリクスLEDにはアノードコモンタイプとカソードコモンタイプがあり極性が逆になります。
以下プログラム内のdigitalWrite()のHIGH/LOWが逆になります。
*アノードコモンタイプの場合:
void setup(){
//16本のピン(2~17)をデジタル出力に設定
for(int i=2;i<=17;i++){
pinMode(i,OUTPUT);
}
}
void loop(){
//行(横)の繰り返し処理
for(int i=2;i<=9;i++){ //行(2~9番ピン)
digitalWrite(i,LOW); //LOWで点灯
//列(縦)の繰り返し処理
for(int j=10;j<=17;j++){ //列(10~17番ピン)
digitalWrite(j,HIGH); //HIGHで点灯
delay(100); //点灯時間
digitalWrite(j,LOW); //列をオフにする
}
digitalWrite(i,HIGH); //行をオフにする
}
}
void setup(){
//16本のピン(2~17)をデジタル出力に設定
for(int i=2;i<=17;i++){
pinMode(i,OUTPUT);
}
}
void loop(){
//行(横)の繰り返し処理
for(int i=2;i<=9;i++){ //行(2~9番ピン)
digitalWrite(i,HIGH); //HIGHで点灯
//列(縦)の繰り返し処理
for(int j=10;j<=17;j++){ //列(10~17番ピン)
digitalWrite(j,LOW); //LOWで点灯
delay(100); //点灯時間
digitalWrite(j,HIGH); //列をオフにする
}
digitalWrite(i,LOW); //行をオフにする
}
}
import processing.video.*;
import processing.serial.*;
Serial myPort;
Capture video;
int w=240;//320;
int h=180;//240;
int tolerance=20;
PFont font;
color targetColor=color(255,0,0);
boolean videoImage=true;
float x;
float y;
float fx;
float fy;
int sumX,sumY;
int pixelNum;
boolean detection=false;
void setup(){
size(w, h);
smooth();
video = new Capture(this, w, h);
font=createFont("Monaco",10);
textFont(font);
noStroke();
myPort=new Serial(this,"/dev/tty.usbserial-A9005baQ",9600);
}
void draw() {
if(video.available()){
video.read();
if(videoImage){
image(video, 0, 0);
}else{
background(0);
}
detection=false;
for(int i=0;i<w*h;i++){
float difRed=abs(red(targetColor)-red(video.pixels[i]));
float difGreen=abs(green(targetColor)-green(video.pixels[i]));
float difBlue=abs(blue(targetColor)-blue(video.pixels[i]));
if(difRed<tolerance && difGreen<tolerance && difBlue<tolerance){
sumX+=(i%w);
sumY+=(i/w);
pixelNum++;
detection=true;
}
}
if(detection){
x=sumX/pixelNum;
y=sumY/pixelNum;
sumX=0;
sumY=0;
pixelNum=0;
}
}
fx+=(x-fx)*0.2;
fy+=(y-fy)*0.2;
myPort.write(int(fx));
fill(255,0,0);
ellipse(fx,fy,20,20);
fill(targetColor);
rect(0,0,10,10);
text(tolerance,20,10);
String s;
if(detection){
s="detect";
}else{
s="none";
}
text(s,40,10);
}
void mousePressed(){
targetColor=video.pixels[mouseX+mouseY*w];
//println(int(red(targetColor))+","+int(green(targetColor))+","+int(blue(targetColor)));
}
void keyPressed(){
if(key=='c'){
video.settings();
}
if(key=='v'){
if(videoImage){
videoImage=false;
}else{
videoImage=true;
}
}
if(key==CODED){
if(keyCode==LEFT){
tolerance-=1;
}
if(keyCode==RIGHT){
tolerance+=1;
}
}
}