Κυριακή 21 Φεβρουαρίου 2010

ΠΑΡΟΥΣΙΑΣΗ ΕΡΓΑΣΙΩΝ

Την Πέμπτη 25 Φεβρουαρίου και ώρα 12:00 θα γίνει η προπαράδοση των εργασιών.
Η τελική παρουσίαση θα λάβει τη μορφή έκθεσης και θα πραγματοποιηθεί κατόπιν συνενόησης μαζί σας την ίδια μέρα στις 21:00 ή την επόμενη. Προτείνεται ως χώρος παρουσίασης ο χώρος των εικαστικών, εκτός εάν το έργο συνδέεται άμεσα με κάποιο άλλο χώρο του τμήτατος.

Ζητείται, εκτός από το έργο σας τα παρακάτω:
Δημιουργία αφίσας υπό την μορφή flyer, δεν προσδιορίζεται το μέγεθος της αφίσας.
PDF αρχείο στο οποίο θα αναφέρονται τα μέλη της ομάδας, θα περιγράφεται η ιδέα, η τεχνολογία που χρησιμοποίησατε, σκίτσα ή σχέδια για την υποστήριξη της ιδέας, καθώς και εικονογραφημένη τεμκηρίωση του έργου σας.

Ως οδηγό μπορείτε να χρησιμοποιήσετε τον παρακάτω σύνδεσμο στο οποίο παρουσιάζονται αντίστοιχες εργασίες του μεταπτυχιακού τμήματος Adaptite Architecture and Computation (http://www.aac.bartlett.ucl.ac.uk/) της Bartlett του πανεπιστημίου UCL.
PDF [23.5MB] http://www.aac.bartlett.ucl.ac.uk/catalogue/book.pdf

Καλή επιτυχία

Τετάρτη 17 Φεβρουαρίου 2010

Harmonic Sequence

Κάναμε ορισμένες αλλαγές στον κώδικα με σκοπό να δημιουργήσουμε νότες και να μπορέσουμε να ελέγξουμε καλύτερα το τελικό αποτέλεσμα. Ο κώδικας είναι:

import processing.opengl.*;
import processing.video.*;
import s373.flob.*;
import ddf.minim.*;
import ddf.minim.signals.*;

Minim minim;
AudioOutput out;
SineWave sine200;
SineWave sine400;
SineWave sine50;
SineWave sine1200;

Capture video;
Flob flob;
ArrayList blobs;

int tresh = 50;
int fade = 50;
int om = 1;
int videores=350;
boolean drawimg=true;
String info="";
PFont font;
int videotex = 3;
int colormode = flob.BLUE;
float fps = 90;

Monoflob mono;

void setup(){

try {
quicktime.QTSession.open();
}
catch (quicktime.QTException qte) {
qte.printStackTrace();
}

size(700,700,OPENGL);
frameRate(fps);
rectMode(CENTER);

video = new Capture(this, videores, videores, (int)fps);
flob = new Flob(this, video, width,height);

flob.setTresh(tresh);
flob.setImage(videotex);
flob.setBlur(0);
flob.setMirror(true,false);
flob.setOm(0);
flob.setOm(1);
flob.setFade(fade);
flob.setMinNumPixels(20);
flob.setMaxNumPixels(500);

flob.setColorMode(colormode);


font = createFont("monaco",9);
textFont(font);

mono = new Monoflob(0,0);

minim = new Minim(this);
out = minim.getLineOut();
sine200 = new SineWave(0, 0, out.sampleRate());
out.enableSignal(sine200);

}

float a0=0;
float b0=0;

void draw(){

if(video.available()) {
video.read();
blobs = flob.calc(flob.binarize(video));
}

if(drawimg)
image(flob.getImage(), 0, 0, width, height);

rectMode(CENTER);
int numblobs = blobs.size();
for(int i = 0; i < numblobs; i++) { ABlob ab = (ABlob)flob.getABlob(i); mono.touch(ab.cx,ab.cy, ab.dimx, ab.dimy); float a=ab.cx; float b=ab.cy; fill (255,0,0); ellipse (a,b,50,50); out.disableSignal(sine200); if (a!=a0 || b!=b0){ sine200 = new SineWave(a, b, out.sampleRate()); out.addSignal(sine200); if ( a > 0 && a < 600) { out.enableSignal(sine200); fill (random(0, 255), random(0, 255), random (0, 255)); rect (0,0,1920,1500); } else { out.disableSignal(sine200); a0=a; b0=b; } mono.render(); fill(255,152,255); rectMode(CORNER); rect(5,5,flob.getPresencef()*width,10); String stats = ""+frameRate+"\nflob.numblobs: "+numblobs+"\nflob.thresh:" +tresh+ " "+"\nflob.fade: "+fade+" "+"\nflob.om: "+flob.getOm()+
"\nflob.image: "+videotex+"\nflob.colormode: "+flob.getColorMode()+"\nflob.presence:"+flob.getPresencef();
fill(0,255,0);
text(stats,5,25);

}


void keyPressed(){
if(key=='b')
drawimg^=true;
if (key=='S')
video.settings();
if (key=='s')
saveFrame("monoflob-######.png");
if (key=='i'){
videotex = (videotex+1)%4;
flob.setImage(videotex);
}
if(key=='t'){
tresh--;
flob.setTresh(tresh);
}
if(key=='T'){
tresh++;
flob.setTresh(tresh);
}
if(key=='f'){
fade--;
flob.setFade(fade);
}
if(key=='F'){
fade++;
flob.setFade(fade);
}
if(key=='o'){
om^=1;
flob.setOm(om);
}
if(key=='c'){
colormode=(colormode+1)%5;
flob.setColorMode(colormode);
}
if(key==' ')
flob.setBackground(video);
}

Πέμπτη 4 Φεβρουαρίου 2010

Take control of 12 LEDs.. v2

..το πρόβλημα με τη σειρά λύθηκε..
..το θέμα τώρα είναι μια μικρή καθυστέρηση που νομίζω οτι υπάρχει κατά την εναλλαγή των LEDs..


arduino code:

int ledPin2 = 2;
int ledPin3 = 3;
int ledPin4 = 4;
int ledPin5 = 5;
int ledPin6 = 6;
int ledPin7 = 7;
int ledPin8 = 8;
int ledPin9 = 9;
int ledPin10 = 10;
int ledPin11 = 11;
int ledPin12 = 12;
int ledPin13 = 13;

int procByte[11]; //incoming byte

void setup(){
// initialize the serial communication:
// Serial.begin(9600);
Serial.begin(115200);

pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(ledPin7, OUTPUT);
pinMode(ledPin8, OUTPUT);
pinMode(ledPin9, OUTPUT);
pinMode(ledPin10, OUTPUT);
pinMode(ledPin11, OUTPUT);
pinMode(ledPin12, OUTPUT);
pinMode(ledPin13, OUTPUT);
}

void loop() {
// check if data has been sent from the computer:
if (Serial.available()>12) {
for (int i=0; i<12; i++) {
// read each byte
procByte[i] = Serial.read();

if (procByte[i] == 'A'){
digitalWrite(ledPin2, HIGH);
}
else if (procByte[i] == 'a'){
digitalWrite(ledPin2, LOW);
}
if (procByte[i] == 'B'){
digitalWrite(ledPin3, HIGH);
}
else if (procByte[i] == 'b'){
digitalWrite(ledPin3, LOW);
}
if (procByte[i] == 'C'){
digitalWrite(ledPin4, HIGH);
}
else if (procByte[i] == 'c'){
digitalWrite(ledPin4, LOW);
}
if (procByte[i] == 'D'){
digitalWrite(ledPin5, HIGH);
}
else if (procByte[i] == 'd'){
digitalWrite(ledPin5, LOW);
}
if (procByte[i] == 'E'){
digitalWrite(ledPin6, HIGH);
}
else if (procByte[i] == 'e'){
digitalWrite(ledPin6, LOW);
}
if (procByte[i] == 'F'){
digitalWrite(ledPin7, HIGH);
}
else if (procByte[i] == 'f'){
digitalWrite(ledPin7, LOW);
}
if (procByte[i] == 'G'){
digitalWrite(ledPin8, HIGH);
}
else if (procByte[i] == 'g'){
digitalWrite(ledPin8, LOW);
}
if (procByte[i] == 'H'){
digitalWrite(ledPin9, HIGH);
}
else if (procByte[i] == 'h'){
digitalWrite(ledPin9, LOW);
}
if (procByte[i] == 'I'){
digitalWrite(ledPin10, HIGH);
}
else if (procByte[i] == 'i'){
digitalWrite(ledPin10, LOW);
}
if (procByte[i] == 'J'){
digitalWrite(ledPin11, HIGH);
}
else if (procByte[i] == 'j'){
digitalWrite(ledPin11, LOW);
}
if (procByte[i] == 'K'){
digitalWrite(ledPin12, HIGH);
}
else if (procByte[i] == 'k'){
digitalWrite(ledPin12, LOW);
}
if (procByte[i] == 'L'){
digitalWrite(ledPin13, HIGH);
}
else if (procByte[i] == 'l'){
digitalWrite(ledPin13, LOW);
}
}
}
}



processing code:

import processing.serial.*;
Serial port;

void setup() {
size(300, 150);
// port = new Serial(this, "COM15", 9600);
port = new Serial(this, "COM15", 115200);
background(255);
stroke (0);
line (150, 0, 150, 150);
}

void draw() {
if (mouseX <150 ) {
port.write('A'); //first led on
port.write('b'); //this led off
port.write('c');
port.write('d');
port.write('e');
port.write('F');
port.write('g');
port.write('H');
port.write('i');
port.write('j');
port.write('K');
port.write('l');
}
else if (mouseX >150 && mouseX < 300 ) {
port.write('a'); //first led off
port.write('B'); //this led on
port.write('c');
port.write('d');
port.write('e');
port.write('f');
port.write('G');
port.write('h');
port.write('I');
port.write('j');
port.write('k');
port.write('L');
}
}

Τετάρτη 3 Φεβρουαρίου 2010

Take control of 12 LEDs.. v1

..με τον παρακάτω κώδικα, μπορέσαμε να ελέγξουμε τα 12 LEDs από ένα arduino board ένα-ένα σε σειρά, αλλά δεν μπορούμε να καθορίσουμε ποιο LedPin θα είναι το πρώτο της σειράς.. οπότε τη μια φορά που τρέχουμε το ProcessingCode είναι πρώτο στη σειρά το LedPin3 δεύτερο το LedPin4 κτλ.. την άλλη φορά το LedPin8,LedPin9 κτλ..

..γενικά έχουμε δοκιμάσει-καταφέρει να ελέγξουμε μέχρι 3 arduino boards από ένα Pc (ένα-ένα το κάθε LED).. αλλά το πρόβλημα είναι πάλι ο καθορισμός των πρώτων LEDs της κάθε σειράς..


arduino code:

int ledPin[] = {1,2,3,4,5,6,7,8,9,10,11,12,13};
int procByte[13]; //incoming byte

void setup()
{
// initialize the serial communication:
Serial.begin(9600);
// initialize the ledPin as an output:
for (int i=0; i<13; i++) {
pinMode(ledPin[i], OUTPUT);
}
}

void loop() {
// check if data has been sent from the computer:
if (Serial.available()>13) {
for (int i=0; i<13; i++) {
// read each byte
procByte[i] = Serial.read();
// pass the value to each pin
analogWrite(ledPin[i], procByte[i]);
}
}
}


processing code:

import processing.serial.*;
Serial port;

void setup() {
size(500, 150);
port = new Serial(this, "COM15", 9600);
background(255);
stroke (0);
line (250, 0, 250, 150);
}

void draw() {
if (mouseX <250 ) {
port.write(255); //first (??) ledPin on
port.write(0); //other ledPins off
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
}
else if (mouseX < 500 ) {
port.write(0); //first(??) ledPin off
port.write(255); //this led on
port.write(0);
port.write(0);
port.write(0);
port.write(255); //this led on
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
port.write(0);
}
}

2ος τρόπος ελέγχου 2d κίνησης με arduino

Εγκαθιστώντας το Python (http://www.python.org/)και τα modules SendKeys kai Serial, στέλνει σήμα το Arduino και ελέγχει τα πλήκτρα του keyboard. Πρέπει το Python να λειτουργεί στο background.

Το δοκιμάσαμε σε ένα παιχνίδι αλλά όπως και με τον προηγούμενο τρόπο λειτουργεί μόνο στο menu και όταν ξεκινά το παιχνίδι παύει να λειτουργεί. Δεν έχουμε βρεί ακόμη την αιτία.

Python code:
import serial
import SendKeys
import os
ser = serial.Serial('COM5', 9600)
#os.system('start "C:\Program Files\StepMania\StepMania.exe"')
LButton = False;
RButton = False;
UButton = False;
DButton = False;
BButton = False;
SButton = False;
while 1:
x=ser.read()
if x == 'l':
LButton = not LButton
if LButton:SendKeys.key_down(39)
else: SendKeys.key_up(39)
elif x == 'r':
RButton = not RButton
if RButton:SendKeys.key_down(37)
else: SendKeys.key_up(37)
elif x == 'u':
UButton = not UButton
if UButton:SendKeys.key_down(40)
else: SendKeys.key_up(40)
elif x == 'd':
DButton = not DButton
if DButton:SendKeys.key_down(38)
else: SendKeys.key_up(38)
elif x == 's':
SButton = not SButton
if SButton:SendKeys.key_down(13)
else: SendKeys.key_up(13)
elif x == 'b':
BButton = not BButton
if BButton:SendKeys.key_down(8)
else: SendKeys.key_up(8)
else:
pass


ser.close()


Arduino code:
const int leftpin = 2;
const int rightpin = 3;
const int uppin = 5;
const int downpin = 4;
const int backpin = 6;
const int startpin = 7;

byte leftButton = LOW;
byte rightButton = LOW;
byte upButton = LOW;
byte downButton = LOW;
byte backButton = LOW;
byte startButton = LOW;

byte buttonRead = LOW;
void setup()
{
pinMode(leftpin, INPUT);
pinMode(rightpin, INPUT);
pinMode(uppin, INPUT);
pinMode(downpin, INPUT);
pinMode(backpin, INPUT);
pinMode(startpin, INPUT);
Serial.begin(9600);
}

void loop()
{
buttonRead = digitalRead(leftpin);
if(buttonRead != leftButton)
{
leftButton = buttonRead;
Serial.print('l');
}
buttonRead = digitalRead(rightpin);
if(buttonRead != rightButton)
{
rightButton = buttonRead;
Serial.print('r');
}
buttonRead = digitalRead(uppin);
if(buttonRead != upButton)
{
upButton = buttonRead;
Serial.print('u');
}
buttonRead = digitalRead(downpin);
if(buttonRead != downButton)
{
downButton = buttonRead;
Serial.print('d');
}
buttonRead = digitalRead(startpin);
if(buttonRead != startButton)
{
startButton = buttonRead;
Serial.print('s');
}
buttonRead = digitalRead(backpin);
if(buttonRead != backButton)
{
backButton = buttonRead;
Serial.print('b');
}
delay(10); // allow some time for the Serial data to be sent
}