Author Archives: Christopher Dalvano

Final Project – Big Brother Time!

Had a great time in the class. It was great meeting each of you and getting the change to learn something new!

My project uses a FSR to manage the color of a box on a grid that correspond to the day and hour of the week. There is a check periodically through each hour, and when there is pressure when checked, it moves the color of the box from white to black gradually. Scott got me going on the hour and day portion which was really helpful.

IMG_0096

 

Processing code:

import processing.serial.*; // import the serial library
import java.util.Date; // import the java date library

Serial mySerial; // an instance of the serial class

int thisBox = 255; // the variable that describes the box color

int prevHour; // a variable to hold the previous hour
// use this to check for a change in the hour
// and reset the color variable

int xPos =0; // a variable for the xPosition of a box (if you want to go that route)
int yPos =0; // a variable for the yPosition of a box (if you want to go that route)

void setup() {
size(700, 600); // a larger window so that it’s more legible
println(Serial.list()); // list our serial ports

String portName = Serial.list()[1]; // get the port name
// open the serial port at 9600 baud
mySerial = new Serial(this, portName, 9600);
// when we receive anewline char, trigger the serialEvent fxn
mySerial.readStringUntil(‘\n’);

// white background
background(255);

// draw a grid in black
for (int i = 0; i<700; i=i+100) {
for (int j = 0; j<1200; j=j+25) { // CD- back to 800
rect(i, j, 100, 25);
}
}
}

void draw() {
// variables to hold the hour and day of the week
int hour = hour(); /// 24 hour clock 9 10 11 12 13 14 15 16 17 18 etc….
int day=new Date().getDay(); //0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturda

// if the hour has changed
if (hour !=prevHour) {
thisBox=255; // make the new fill color white
prevHour=hour; // set the previous hour to this hour
}

fill(thisBox); // fill color for the box you’re currently writing to

// you can set this up to change a variable for the box x,y position
// so that if day == 1, xPos = 0. if day==2, xPos=100 (etc).
// and for the hours if hour ==9, yPos=0. if hour=10, yPos =100 (etc.)

if (hour == 1) { // if 9am CD-back to 9
yPos =0;
} else if (hour==2) { // if 10 am
yPos=25;
} else if (hour==3) { // if 10 am
yPos=50;
} else if (hour==4) { // if 10 am
yPos=75;
} else if (hour==5) { // if 10 am
yPos=100;
} else if (hour==6) { // if 10 am
yPos=125;
} else if (hour==7) { // if 10 am
yPos=150;
} else if (hour==8) { // if 10 am
yPos=175;
} else if (hour==9) { // if 10 am
yPos=200;
} else if (hour==10) { // if 10 am
yPos=225;
} else if (hour==11) { // if 10 am
yPos=250;
} else if (hour==12) { // if 10 am
yPos=275;
} else if (hour==13) { // if 10 am
yPos=300;
} else if (hour==14) { // if 10 am
yPos=325;
} else if (hour==15) { // if 10 am
yPos=350;
} else if (hour==16) { // if 10 am
yPos=375;
} else if (hour==17) { // if 10 am
yPos=400;
} else if (hour==18) { // if 10 am
yPos=425;
} else if (hour==19) { // if 10 am
yPos=450;
} else if (hour==20) { // if 10 am
yPos=475;
} else if (hour==21) { // if 10 am
yPos=500;
} else if (hour==22) { // if 10 am
yPos=525;
} else if (hour==23) { // if 10 am
yPos=550;
} else if (hour == 0) { // if 9am CD-back to 9
yPos =575;
}

if (day == 1) { // if Monday
xPos =0;
} else if (day ==2) { // if Tuesday
xPos =100;
} else if (day ==3) { // if Tuesday
xPos =200;
} else if (day ==4) { // if Tuesday
xPos =300;
} else if (day ==5) { // if Tuesday
xPos =400;
} else if (day ==6) { // if Tuesday
xPos =500;
} else if (day ==0) { // if Tuesday
xPos =600;
} /// continue for the other days of the week thru Fri

// draw the box
rect(xPos, yPos, 100, 25);
}
// serialEvent only fires when a message is received from the Arduino
// in this case it’s only once a minute (because that’s how often the
// Arduino fires
void serialEvent(Serial port) {
if (port == null) return; // make sure there’s information

String inString = port.readStringUntil(‘\n’); // read until the newline character

if (inString != null) { // as long as there’s an actual word in there
inString = trim(inString); // trim off any whitespace:
//}
String check = “working”;
println(inString);
if (inString.equals(check)) { // if the arduino sent working”
println(“here”);
if(thisBox>5)
thisBox = thisBox-25; // make the color for the box a little darker
// 4*60=240, which would be pretty close to black if someone is in the chair the full hour
} else {
// nothing to do if someone’s not working
}
}
}

 

Arduino code

int fsrVal; // variable to hold the senspr value

void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // start serial communication
}

void loop() {
// put your main code here, to run repeatedly:
fsrVal = analogRead(A0); // read the sensor, save in variable

if (fsrVal < 999) { // if the sensor value is less than 999
Serial.println(“working”); // send a “working” message
} else if (fsrVal >= 1000) { // if it’s greater or equal to 1000
Serial.println(“notWorking”); // send the “not working” message
}
delay(600); // wait one minute before the next read
}

 

Computing

2 topics kept jumping into my head as a read this. People are strange was the first thing, and the cycle of media and technological innovation was the second. “…cultural categories and concepts are substituted, on the level of meaning and/or the language, by new ones which derive from computer’s ontology, epistemology and pragmatics. New media thus acts as a forerunner of this more general process of cultural re-conceptualization.” Like we talk about in class, my computer doesn’t do anything until I tell it to – replace “computer’s” with “the user’s” in the above quote and it basically says that we use new media to change our culture to fit our needs. Great, except people are strange. Don’t get me wrong, we are all strange in our own way, it’s what is great about each of us, beautiful. The increased interaction brought on by new media creates a wider spectrum of “strangeness” in mainstream life. Now everyone can contribute to our culture – not just those of us within a standard deviation or so. How does that effect generation to come.

I look at how our culture has changed because of this and I think of twitter and Instagram (etc). Seems that the changes to our culture have changed it from people connecting in-person and wanted the connection to relate to people to just needing to update my social media. We have replaced sitting down for a meal with people with taking pictures of food and sharing them – far from the same thing. This starts to get into the second idea of the cycle of media and technology.

I started thinking about what drives this, does twitter drive the need for new phones that allow me to tweet from anywhere, or does the creation of the phone with this capability allow for the creation of twitter. Does the technology drive the creation of media, or does the want for new media drive technology. In most cases, I feel like the idea of something, then creates a need for the tool to accomplish it; but I am not sure that’s that same pattern for media. It seems that the technology needs to be there or at least mostly there, then the application of that technology is created (then maybe technology updates a bit). Does this make sense? Are we controlling our own destiny?

Blank

Trying to get the image to appear with circles rather than triangles – the base of the image is circular. I can’t get the image to appear in the window. Its just blank – and pretty, pretty, pretty…frustrating.

**I took the code from the triangle image post as a start**

PImage img;

void setup(){
size(1000,1000);
img = loadImage(“protrait.jpg”);
img.filter(POSTERIZE,10);
smooth();
}

void draw(){
background(255);
loadPixels();

for(int y = 0; y< img.height;y=+10){
for(int x=0;x<img.width+5;x+=5){
int loc=x+y*img.width;

stroke(img.pixels[loc]);
fill(img.pixels[loc]);

if(x%10==0)  elipse (y+ 10,16);
else  elipse (z+16,16);

}
}
}
void mousePressed(){
save(int(random(10))+”.jpg”);
}

Pong

I started with Pong that I got from a site: http://www.123mylist.com/2013/12/basic-pong-game-using-processing.html

I t was pretty great so I practiced for a while. Below is the code for the basic. Once I had my fill, I started changing the different parameters. First I had to understand what the deal was so I added comments and then changed things.

FYI – this is the most addicting thing ever!

int base=40;
int x,y,gameScore=0;
int changeX=-5;
int changeY=-5;
int gameOver=0;
void setup()
{
size(760, 640);
x=(int)random(width);
y=height-base;
}
void draw()
{
if(gameOver==0)
{
background(0);
text(“SCORE:”+gameScore+”00”,width/2,height/2);
rect(mouseX,height-base,200,base);
ellipse(x,y,10,10);
x=x+changeX;
y=y+changeY;
if(x<0 | x>width)
{
changeX=-changeX;
}
if(y<0)
{
changeY=-changeY;
}
if(y>height-base)
{
//check whether it is falling inside the rectangle or not
if(x>mouseX && x<mouseX+200)
{
changeY=-changeY; //bounce back
gameScore++;

}
else
{
gameOverSplash();
}
}
}
else
{
background(100,100,200);
text(“Game Over!”,width/2,height/2);
text(“CLICK TO RESTART”,width/2,height/2+20);
}
}
void gameOverSplash()
{
gameOver=1;
}
void mouseClicked()
{
changeY=-changeY;
gameScore=0;
gameOver=0;

}

Random…

Sorry to be a stickler here but…If you publish a book of random numbers, I am not sure you can say they are still random.

 

Catnip

Our assignment was timely for me this weekend as I headed to visit my uncle and family. Three awesome kids and two very playful cats! So Goofy poke a dot socks a few hangers and I was set to go. I didn’t get a video while I was with them  and the cats, but it worked well. The socks spun as they were supposed to and the hangers provided a nice bounce.

Vid1