Archive by Author
Image

Lost Arduino Kit?

20 Dec

Lost Arduino Kit?

Did anyone forget their Arduino kit in the BDA studio? Message me if this is yours!

Image

Final Project – Shadowbox (aka Mystery Box) – Kevin Desautels, Dennis MacAvaney, Kierra Thomas

19 Dec

Final Project - Shadowbox (aka Mystery Box) -  Kevin Desautels, Dennis MacAvaney, Kierra Thomas

Shadowbox is an installation that manipulates shadows. It works best in a dark room with a single light source. The goal of this project was to produce a fun, interactive piece that is both reactive and somewhat unpredictable (to add interest).
The Box contains an Arduino, a webcam, 2 potentiometers, and has a frosted plastic screen on which to cast shadows. The frosted plastic aids the processing script in blob detection by filtering out color. One potentiometer controls the color of the projection, and one controls the shakiness of the edges drawn. The arduino then relays the raw information to a laptop, which runs a processing script. The processing script captures video frames from the webcam, and attempts to draw the edges of the shadows it views from the inside of the plastic screen, and then draw lines from the center of the blobs to the outer edge (to act as a fill).
Because of the roughness of the blobs detected by the processing code, the projected image is abstract and interacts somewhat unpredictably. Shadowbox is a good proof of the concept, but could use streamlining and more accurate interpretations of the shadows. This would help to produce a more consistently reactive and abstract result. More controls could be added to give the user more options.

ARDUINO CODE:

int colorPot=0;//determines color in Processing (float Color)
int weirdPot=0;//determines shaky-ness of edges (float Weird)

void setup(){
Serial.begin(9600);
}

void loop(){
colorPot=analogRead(A0);
weirdPot=(analogRead(A1)+9000);//adds 9000 to variable to differentiate from colorPot
colorPot=map(colorPot,510,1023,0,510);
Serial.println (colorPot);
delay(50);//for stability
Serial.println (weirdPot);
delay(50);
}

PROCESSING CODE:

import processing.video.*;
import blobDetection.*;
import processing.serial.*;

Capture cam;
BlobDetection theBlobDetection;
PImage img;
boolean newFrame=false;
Serial myPort;
float Temp=0;
float Color=0;
float Weird=0;

// ================================================== setup()
void setup()
{
println(Serial.list());//Select serial port
myPort = new Serial(this, Serial.list()[3], 9600);
size(640, 480);
String[] cameras = Capture.list(); //Select camera
if (cameras.length == 0) {
println(“There are no cameras available for capture.”);
exit();
} else {
println(“Available cameras:”);
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
cam = new Capture(this, cameras[3]); //iSight
//cam = new Capture(this, cameras[15]); //webcam
cam.start();
}
// BlobDetection
// img which will be sent to detection (a smaller copy of the cam frame);
img = new PImage(80,60);
theBlobDetection = new BlobDetection(img.width, img.height);
theBlobDetection.setPosDiscrimination(false);//"true" makes blobs favor bright areas, mostly works
theBlobDetection.setThreshold(0.8f); //detection threshold
}

// ================================================== captureEvent()
void captureEvent(Capture cam)
{
cam.read();
newFrame = true;
}

// ================================================== draw()
void draw()
{
if (newFrame)
{
newFrame=false;
background(0, 255); //background color
img.copy(cam, 0, 0, cam.width, cam.height,
0, 0, img.width, img.height);
fastblur(img, 2);
theBlobDetection.computeBlobs(img.pixels);
drawBlobsAndEdges(false,true);
}
}

// ================================================== drawBlobsAndEdges()
void drawBlobsAndEdges(boolean drawBlobs, boolean drawEdges)
{
noFill();
Blob b;
EdgeVertex eA,eB,vA,vB;

Temp=0;
String inString=myPort.readString();//Read from serial port

if(inString!=null){
inString = trim(inString);
Temp = float(inString);

if(Temp<9000){//filter out colorPot value, set = float Color
Color=Temp;
}else{//filter out weirdPot value, set = float Weird
Weird=(Temp-9000);
Weird=map(Weird,550,1023,0,.02);
if(Weird<0){
Weird=0;}
println(Weird);
}
}else{
Temp=0;
}

for (int n=0 ; n<theBlobDetection.getBlobNb() ; n++)//blob-scanning
{
b=theBlobDetection.getBlob(n);
if (b != null)
{
if (drawEdges)//Edges
{
//====================================color scrolling
float R=0;
float G=0;
float B=0;
if(Color255){
B=(Color-255);
}else{
B=0;}
G=(255-R-B); //R+G+B = 256

strokeWeight(5);
stroke(R,G,B);
for (int m=0;m 0){
eB.x += random(-Weird,Weird);//adds random value to edge endpoint based on float Weird
eB.y += random(-Weird,Weird);
}
if (eA !=null && eB !=null){
line(
eA.x*width, eA.y*height,
eB.x*width, eB.y*height);
line(
b.x*width, b.y*height,
eB.x*width, eB.y*height);
}
}
}//end edge drawing
}
}//end blob-scanning loop
}
// The following code is unneccesary, but adds stability to edges
// Super Fast Blur v1.1
// by Mario Klingemann
//
// ==================================================
void fastblur(PImage img,int radius)
{
if (radius<1){
return;
}
int w=img.width;
int h=img.height;
int wm=w-1;
int hm=h-1;
int wh=w*h;
int div=radius+radius+1;
int r[]=new int[wh];
int g[]=new int[wh];
int b[]=new int[wh];
int rsum,gsum,bsum,x,y,i,p,p1,p2,yp,yi,yw;
int vmin[] = new int[max(w,h)];
int vmax[] = new int[max(w,h)];
int[] pix=img.pixels;
int dv[]=new int[256*div];
for (i=0;i<256*div;i++){
dv[i]=(i/div);
}

yw=yi=0;

for (y=0;y<h;y++){
rsum=gsum=bsum=0;
for(i=-radius;i>16;
gsum+=(p & 0x00ff00)>>8;
bsum+= p & 0x0000ff;
}
for (x=0;x>16;
gsum+=((p1 & 0x00ff00)-(p2 & 0x00ff00))>>8;
bsum+= (p1 & 0x0000ff)-(p2 & 0x0000ff);
yi++;
}
yw+=w;
}

for (x=0;x<w;x++){
rsum=gsum=bsum=0;
yp=-radius*w;
for(i=-radius;i<=radius;i++){
yi=max(0,yp)+x;
rsum+=r[yi];
gsum+=g[yi];
bsum+=b[yi];
yp+=w;
}
yi=x;
for (y=0;y<h;y++){
pix[yi]=0xff000000 | (dv[rsum]<<16) | (dv[gsum]<<8) | dv[bsum];
if(x==0){
vmin[y]=min(y+radius+1,hm)*w;
vmax[y]=max(y-radius,0)*w;
}
p1=x+vmin[y];
p2=x+vmax[y];

rsum+=r[p1]-r[p2];
gsum+=g[p1]-g[p2];
bsum+=b[p1]-b[p2];

yi+=w;
}
}
}

Final Project Proposals – Shadow Box – Dennis, Kierra, Kevin

2 Dec

Description:

Our Project would be a box (about 2x2x2 feet) that interprets shadow-puppets that are casted on it by people, and project the result onto a screen.  The box would have a translucent screen on one face that would act like a screen for shadows to be casted onto.  A webcam inside the box would read the shadows (sending them to a laptop), which would be abstracted and projected onto a larger screen on a wall nearby.  An Arduino could be used to manage additional dials, sensors, and/or buttons on the box that would, for example, change the background color or cycle through textures on the projected image.

This would be a fun installation for children in a daycare or in waiting rooms, or just as an interesting art installation.

1202131825

Materials:

Webcam, Arduino, Laptop, Projector and screen, buttons/LEDs/dials/misc. hardware

Plywood, or similar material for box (Alternatively, a recycled object like an old TV or suitcase.  Patterns or form could be 3D printed or laser-cut.)

Translucent screen (hard or soft plastic)

External light (for shadows; could be lamp or overhead light)

Schedule:

Dec. 3-8

Dennis: Coding- blob detection, texturing, Arduino sensor and input management

Kevin and Kierra: Box Build- box design, sensor and input mounting, light placement, screen mounting, box finish(es)

Dec. 9-12

All: Troubleshooting (projector, misc. software issues), calibration (webcam and light placement, cam calibration), integrating parts (misc hardware issues)

Image

Homework 04 -NoiseMaker- Dennis MacAvaney

5 Nov

Homework 04 -NoiseMaker- Dennis MacAvaney

/*While the button is pressed, the buzzer makes a tone determined by the potentiometer.
If you double click the button, the buzzer locks on until you double click again.
If you turn the pitch up too high, the buzzer will turn off unless the button is being held down.*/

int count=0;                      //determines speed range of double click (see below)
int val=0;                           //button state
int oldVal=0;                    //previous button state
int state=0;                      //state toggled by a double click (buzzer locks on)
int pitch=0;
int sensorRead=0;         //reads from potentiometer
int button=7;                  //input, turns buzzer on while pushed
int green=8;
int mic=9;                       //buzzer
int red=10;

void setup(){
pinMode(button,INPUT);
pinMode(green,OUTPUT);
pinMode(red,OUTPUT);
pinMode(mic,OUTPUT);
}

void loop(){

val=digitalRead(button);                //reads button

if(state==1){                                    //checks state of buzzer
digitalWrite(green,HIGH);             //OUTPUT (1)
sensorRead = analogRead(A0);
pitch = map(sensorRead, 0, 1023, 120, 1410);                 //map pitch
tone(mic, pitch, 10);                                                             //play pitch
if(pitch>1400){                 //if the pitch is too high, it switches the buzzer off unless the button is being pressed
digitalWrite(red,HIGH);
state=0;
}
}else{
digitalWrite(green,LOW);                                   //OUTPUT (0)
digitalWrite(red,LOW);
}
if(val==HIGH){                                                     //if the button is pushed once:
digitalWrite(green,HIGH);                                 //OUTPUT (1)
sensorRead = analogRead(A0);
pitch = map(sensorRead, 0, 1023, 120, 1410);   //map pitch
tone(mic, pitch, 10);                                               //play pitch
if(pitch>1400){                                                        //pitch regulator
digitalWrite(red,HIGH);
state=0;
}
oldVal=val;
delay(15);d
for(count=0; count<30; count++){                 //Loop waits for a second button click, for about 1/2 second
val=digitalRead(button);
if(val==LOW){
oldVal=val;                                                         //records previous value
if(state==0){
digitalWrite(green,LOW);                                //OUTPUT (0)
digitalWrite(red,LOW);
}
}else{
digitalWrite(green,HIGH);                                                     //OUTPUT (1)
sensorRead = analogRead(A0);
pitch = map(sensorRead, 0, 1023, 120, 1410);                 //map pitch
tone(mic, pitch, 10);                                                             //play pitch
if(pitch>1400){                                                                      //pitch regulator
digitalWrite(red,HIGH);
state=0;
}
}
if((val==HIGH)&&(oldVal==LOW)){                                    //checks if button is released and pressed again
oldVal=val;
state=1-state;                                                                      //toggles state of buzzer (lock on/off)
if(state==1){
digitalWrite(green,HIGH);//OUTPUT (1)
sensorRead = analogRead(A0);
pitch = map(sensorRead, 0, 1023, 120, 1410);             //map pitch
tone(mic, pitch, 10);                                                         //play pitch
if(pitch>1400){                                                                  //pitch regulator
digitalWrite(red,HIGH);
state=0;
}
}else{
digitalWrite(green,LOW);                          //OUTPUT (0)
digitalWrite(red,LOW);
}
delay(15);
}else{
delay(15);               //the loop delays for 15ms either way, and is repeated 30 times
}
}//End for loop
}//End if statement (before for loop)
}//End void loop

Image

Homework 03 -Button-controlled Servo- Dennis MacAvaney

31 Oct

Homework 3 -Button-controlled Servo- Dennis MacAvaney

#include

Servo myservo;

int button1=5;
int button2=6;
int val=0;
int valB1=0;
int valB2=0;
int valNet=0;

void setup()
{
myservo.attach(9);
pinMode(button2, INPUT);
pinMode(button1, INPUT);
}

void loop()
{
if(digitalRead(button1)==HIGH){//incriment valB1 whenever Arduino reads B1 is pushed
valB1++;
}else{valB1–;}

if(digitalRead(button2)==HIGH){//reverse whenever Arduino reads B1 is pushed
valB2++;
}else{valB2–;}

valNet=(valB1-valB2);//determines the net movement of the servo
if(valNet>179){//caps net value at 179 and 0
valNet=179;}
if(valNet<0){
valNet=0;}
valNet = map(valNet, 0, 179, 0, 179);
myservo.write(valNet);//sends servo resulting valNet
delay(10);

}

Image

Homework 02 -SOS- Dennis MacAvaney

29 Oct

Assignment 02 -SOS- Dennis MacAvaney

int red=3; //”SOS” is signed with 3 short signals, 3 long, and then 3 short again
int blue=5; //this is the same setup as the RGB example in class
int green=6;
int count=0; //this will keep track of how many times a light flashes in each loop

void setup(){
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);

}

void loop(){

for(count=0;count=3, and
digitalWrite(red, HIGH); //count will go up by 1 at the end of each iteration (“count++”)
digitalWrite(blue, HIGH); //This is the first short-signal loop
digitalWrite(green, HIGH);
delay(500);
digitalWrite(red, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, LOW);
delay(250);
}

delay(250);

for(count=0;count<3;count++) //3 long signals
{
digitalWrite(red, HIGH);
digitalWrite(blue, HIGH);
digitalWrite(green, HIGH);
delay(1000);
digitalWrite(red, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, LOW);
delay(500);
}

for(count=0;count<3;count++) //3 short signals
{
digitalWrite(red, HIGH);
digitalWrite(blue, HIGH);
digitalWrite(green, HIGH);
delay(500);
digitalWrite(red, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, LOW);
delay(250);
}

delay(750); //a delay at the end before SOS is signaled again

}