I don’t think computing on its own is a significant concept to me. It is such a huge part of my life, between this class, my computer science minor, and my physics research, that i basically don’t see it anymore, just specific applications of it. I used so see it as something amazing and wonderful, that was a very pleasant break from my other classes, like languages. Now though, I see that its inherent logic is convoluted by people in any of the projects that are sufficiently complicated to be worth something, and so while simple coding and computing has some inherent beauty for me, most is so hacky and misleading that I see it mostly as a powerful tool. It is necessary for a great many things, but it is only a necessary feature, it does not increase the value of whatever it is involved in inherently.
What computing means to me-
Though I tend to believe that the modern world is complex, by learning the absolute basics of computing I am closer to understanding the ways in which technologies influence the current society. It has added a lot of stress to my life as I tend to not be great at learning languages, nor practicing them. The learning that I currently have access to is through practice and readings. I think that the practice aspect is helping me understand the concept and the hard work that goes into it. The reading aspect is helping me be more contemplative of the activities that I participate in eg. facebook or instagram. It has also made me more critical of the debates that occur today, eg. the Mark Zuckerberg trail (hearing?).
I don’t know if it’s making me a better person, but it is making me more aware of my surroundings and allowing me to understand how some applications such as Waze utilize my information. I think that computing so far has pushed me to work towards understanding and manipulating a language to do what I need it to. So far, it’s been a learning experience to say the least, but it was worth the struggle to know what I know now.
My Controller – Red Pill or Blue Pill?
My controller is a further development on the matrix project that I did last week. I decided to implement the iconic scene of the matrix that asked the protagonist to choose between a red pill and a blue one. If he chose the red pill, the ‘matrix’ would be revealed and he would see the ‘unmasked’ world. If he chose the blue pill, he would be able to believe the farce of the world and go back to his normal life.
I decided to give the user the same choice. In my controller there are two buttons, one red and one blue. These buttons determine what is going to be on the screen. I decided that for the blue button, 1/3 positive quotes would momentarily display on the screen. This was to represent the farce that is present. To communicate that good things happen and thus mask us from the nonsensical nature of society. The blue pill quotes show only momentarily so that this ‘return to normalcy’ is also represented. While the red pill shows a quote that was said by the creators “There is something wrong with the world. You don’t know what it is, but it’s there like a splinter in your mind, driving you mad”.
Here is the code for the Arduino:
int redButton = 10; int blueButton = 9; int b = 0; int r = 0; int running = 2; void setup() { // put your setup code here, to run once: pinMode(redButton, INPUT); pinMode(blueButton, INPUT); Serial.begin(9600); } void loop() { if (digitalRead(blueButton) == HIGH && digitalRead(redButton) == LOW) { b = 1; } else if(digitalRead(blueButton == LOW)){ b = 0; } if (digitalRead(redButton) == HIGH && digitalRead(blueButton) == LOW) { r = 1; } else if(digitalRead(redButton == LOW)){ r = 0; } Serial.print(b); Serial.print(','); Serial.println(r); }
Here is the code for processing:
int max_num_col = 98; //int buttport=2; int prevb = 0; int prevr = 0; String[] z; int r=0; int b=0; String s; int num_col = floor(random(1, max_num_col)); // randomize total num of columns to be created for each loop int[] xPosi; // array to store random initial x positions int[] yOffset; // array to store random initial y position offset //String name = "vitoria"; char[] poo = {'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a', 'v', 'i', 't', 'o', 'r', 'i', 'a'}; String a ="There is something wrong with the world. You don’t know what it is, but it’s there like a splinter in your mind, driving you mad."; String[] bla = {"Australia became the 25th country to achieve marriage equality", "Women in Saudi Arabia were granted permission to drive starting in June.", "There’s a cat in New Zealand who has been sneaking out and stealing men’s underwear and socks."}; import processing.serial.*; Serial myPort; void setup() { size(1000, 500); frameRate(60); colorMode(HSB, 360, 100, 100); printArray(Serial.list()); String portname=Serial.list()[2]; println(portname); myPort = new Serial(this, portname, 9600); PFont font; font = createFont("Arial Black", 10); textFont(font); xPosi = new int[num_col]; yOffset = new int[num_col]; for (int i=0; i<num_col; i=i+1) { xPosi[i] = floor(random(size_x/text_size))*text_size; yOffset[i] = floor(random(-size_y, size_y)); } } void draw() { println(r, b); fill(0, 10); // the smaller the alpha, the longer the tail noStroke(); rect(0, 0, size_x, size_y); // fill(random(360),100,100); // char with color fill(120, 100, 100); // green char textSize(text_size); for (int i=0; i<num_col; i++) { //int i_char = floor(random(255)); //char T = char(i_char); char T = poo[i]; text(T, xPosi[i], y+yOffset[i]); } y = y + floor(text_size/1.1); // spacing btw char if (y>size_y*1.2) { y = -400; num_col = floor(random(1, max_num_col)); xPosi = new int[num_col]; yOffset = new int[num_col]; for (int i=0; i<num_col; i=i+1) { xPosi[i] = floor(random(size_x/text_size))*text_size; yOffset[i] = floor(random(-size_y, size_y)); } } if (b == 1 && prevb == 0) { s = bla[round(random(1, 2))]; textSize(20); fill(#3E5AE3); text(s, 30, 250, 7000, 1000);// Text wraps within text box } if (r == 1) { textSize(14); fill(#F21414); text(a, 10, 250, 7000, 1000); } prevb = b ; prevr = r; } void serialEvent(Serial myPort) { String x=myPort.readStringUntil('\n'); if (x!=null) { x=trim(x); z = x.split(","); b = int(z[0]); r = int(z[1]); } }
Here is how it looks:
What does computing mean to me?
I have been feeling really conflicted about whether computing has been adding any meaning to my life. It is something that I have been reflecting on tremendously over the semester in order to see whether I should go on with IM or choose another path. I love coding in the short-term. It is both fun and challenging, and provides some sort of intellectual release from the immense amount of readings and essays I have to do for my other classes. However when I found myself doing the mid-term project, or the 2 hour lab sessions on Wednesday, something about it wasn’t entirely enjoyable. Of course, I realise that what you enjoy doing won’t always be fun. There will be challenging moments. However, the longer I take to code, the less patient I get. The more quickly I want the answers. This is something that has always been present in how I complete tasks. However it is especially present in coding. I believe this is because I don’t consider myself to have a strong skill-set in quantitative reasoning, which is why it can get challenging as I dedicate more and more time to my projects. Another reason is due to the fact that I tend to look for how my impact on a project can benefit others on the scale of the greater good. Of course it can be undeniably challenging to find benefits for the greater good in an introductory IM course, I can’t get all my answers immediately. It takes time, patience and effort to build an impact. I guess computing has revealed to me as to how impatient I am, and I think it has really helped me become more patient while doing my work. Something else that worries me about computing is sustainability, how can I be sustainable with my resources while computing? I have noticed that me and my other peers in class are quite unsustainable with the resources we use for our project sometimes, going through multiple cardboards and other materials before we get the right shape or structure. I haven’t found a solution to the issue of sustainability yet.
So, I know the what I have mentioned above makes me seem pretty uncertain about where I stand on IM and how it has added to my life, but regardless of my doubts about how IM could impact me in the future, it has offered me incredibly valuable lessons for the now. One that I have already mentioned above, it has taught me an incredible amount of patience. It has also helped me appreciate the little things rather than looking at the larger picture: the way we check sections of our code one by one as we complete it rather than editing once we completely finish writing the code like we usually do while writing an essay has helped me appreciate the small sections of a larger work more profoundly. It has helped me be more attentive to the smaller details. I have also found logic in code to be incredibly compelling. I am a huge fan of philosophy and the way constructs a rational, clear argument. Although I am nowhere near great at understanding logic of code, I tend to draw many parallels between computing and writing philosophical arguments, which have rational, logical steps to show a particular output. I find a lot of beauty in this parallel, and it helps me appreciate computing more. I have struggled quite a lot with computing, and am still struggling. Perhaps the struggle makes me feel uncertain as to where I stand, but undoubtedly, it has filled my life with wondrous reflections, useful lessons, and valuable insight as to who I am as a creative individual.
Assignment Week #11
For this week’s project, we needed to find a way to combine both Arduino and Processing. I ended up basing the code off of the art project that we did a few weeks ago. I tried to think of some ways to use different things other than the knobs such as Aaron suggested, and ended up using two controllers: a knob and a pressure sensor.
I just thought it would be interesting to work with both these sensors in relation to one another and see the power of each in relation to affecting the processing drawing.
Codes:
Arduino:
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0){
char inByte=Serial.read();
int sensor = analogRead(A0);
delay(0);
int sensor2 = analogRead(A1);
delay(0);
Serial.print(sensor);
Serial.print(‘,’);
Serial.println(sensor2);
}
}
Processing:
import processing.serial.*;
Serial myPort;
int xPos=0;
int yPos=0;
Shape shape1;
Shape shape2;
Shape shape3;
Shape shape4;
Shape shape5;
Shape shape6;
Shape shape7;
Shape shape8;
int x1= mouseX;
int y1 = mouseY;
color red = color(255, 0, 0, 20);
color green = color(0, 255, 0, 30);
color blue = color(0, 0, 255, 10);
void setup(){
size(960,720);
printArray(Serial.list());
String portname=Serial.list()[3];
println(portname);
myPort = new Serial(this,portname,9600);
myPort.clear();
myPort.bufferUntil(‘\n’);
smooth();
colorMode(HSB);
shape1 = new Shape(xPos, yPos, 250, 150, 250, 250, 100, 100);
shape2 = new Shape(xPos, yPos, 150, 250, 250, 250, 400, 200);
shape3 = new Shape(xPos, yPos, 400, 250, 250, 250, 100, 400);
shape4 = new Shape(xPos, yPos, 250, 400, 250, 250, 50, 290);
}
void draw(){
background(100, 105, 100);
shape1.display();
shape2.display();
shape3.display();
shape4.display();
noStroke();
}
void serialEvent(Serial myPort){
String s=myPort.readStringUntil(‘\n’);
s=trim(s);
if (s!=null){
int values[]=int(split(s,’,’));
if (values.length==2){
xPos=(int)map(values[0],0,1023,0, width);
yPos=(int)map(values[1],0,1023,0, height);
}
}
println(xPos);
myPort.write(‘0’);
}
Class Processing:
class Shape{
//Variables
int x1, y1, x2, y2, x3, y3, x4, y4;
//The Constuctor
Shape(int px1, int py1, int px2, int py2, int px3, int py3, int px4, int py4){
x1 = px1;
y1 = py1;
x2 = px2;
y2 = py2;
x3 = px3;
y3 = py3;
x4 = px4;
y4 = py4;
}
//Functions
void display(){
x1 = xPos; //use xPos and yPos
y1 = yPos;
quad(x1, y1, x2, y2, x3, y3, x4, y4);
}
}
Arduino + Processing = Lit
For this week’s assignment, I added a physical controller in the form of a joystick to my Snake game. The joystick had 3 outputs (analog x-coordinate, analog y-coordinate, and digital click) so it was a bit difficult to get everything right in the beginning.
I ran into some more issues when trying to connect the controller output to the processing game code: the joystick values were just not being updated into the game. I tried printing out the values generated by the joystick and they were correct. Honestly had no clue why the snake just wouldn’t turn. Oh stubborn snake. Upon closer inspection, there seemed to be a 2-ish second delay between the commencement of the game and the updating of the value generated by the joystick into the game. I added a 2 second delay to the beginning of the game and everything seems to work now. Mashallah
Here is a video demonstration of my game:
Here is my code:
import processing.serial.*;
Serial myPort;
//int[] dataIn = new int[2]; // a list to hold data from the serial ports
ArrayList<Integer> positionsX = new ArrayList<Integer>();
ArrayList<Integer> positionsY = new ArrayList<Integer>();
int dimSquare = 40;
int xPos = 0;
int yPos = 0;
int poo = 0;
int internalInput = -1;
int dim = 800;
int positionX = 5;
int positionY = 5;
int foodX = 15;
int foodY = 15;
int [] dirX = {1,-1,0,0};
int [] dirY = {0,0,1,-1};
int direction = 0;
int speedOfGame = 10;
boolean gameover = false;
class gameBoard{
gameBoard(){}
void drawLines(){
noFill();
stroke(0);
strokeWeight(1);
for(int i = 0; i < dim; i++){
line(dimSquare*i, 0, dimSquare*i, dim);
line(0, dimSquare*i, dim, dimSquare*i);
}
}
}
class snake{
snake(){
positionX = positionX*dimSquare;
positionY = positionY*dimSquare;
}
void drawSnake(){
fill(0,255,0);
noStroke();
for(int i = 0; i < positionsX.size() ; i++){
rect(positionsX.get(i)*dimSquare, positionsY.get(i)*dimSquare, dimSquare, dimSquare);
}
if(frameCount % speedOfGame == 0){
positionsX.add(0, positionsX.get(0) + dirX[direction]);
positionsY.add(0, positionsY.get(0) + dirY[direction]);
//positionsX.add(0, dirX[direction]);
//positionsY.add(0, dirY[direction]);
positionsX.remove(positionsX.size() – 1);
positionsY.remove(positionsY.size() – 1);
}
}
void growSnake(){
positionsX.add(1, positionsX.get(0) + dirX[direction]);
positionsY.add(1, positionsY.get(0) + dirY[direction]);
}
}
class food{
food(){
}
void drawFood(){
fill(255, 0, 0);
rect(foodX*dimSquare, foodY*dimSquare, dimSquare, dimSquare);
}
}
gameBoard a;
snake b;
food c;
void setup(){
size(802, 802);
printArray(Serial.list());
String portname=Serial.list()[8];
println(portname);
myPort = new Serial(this,portname,9600);
myPort.clear();
myPort.bufferUntil(‘\n’);
a = new gameBoard();
b = new snake();
c = new food();
positionsX.add(5);
positionsY.add(5);
delay(2000);
}
void draw(){
if(gameover == false){
background(255);
//delay(30);
//a.drawLines();
b.drawSnake();
c.drawFood();
if(positionsX.get(0) == foodX && positionsY.get(0) == foodY){
foodX = (int)random(0,20);
foodY = (int)random(0,20);
b.growSnake();
}
if(positionsX.get(0) < 0 || positionsY.get(0) < 0 || positionsX.get(0) >= 20 || positionsY.get(0) >= 20){
gameover = true;
fill(0);
textSize(30);
textAlign(CENTER);
text(“GAME OVER.”,width/2,height/2);
}
if(positionsX.size() == 20){
gameover = true;
fill(0);
textSize(30);
textAlign(CENTER);
text(“YOU WINNNNN.”,width/2,height/2);
}
}
if(xPos == 1023){
internalInput = 0;
}
if(xPos == 0){
internalInput = 1;
}
if(yPos == 1023){
internalInput = 2;
}
if(yPos == 0){
internalInput = 3;
}
if(internalInput != -1){
direction = internalInput;
}
//println(xPos);
//println(yPos);
}
void serialEvent(Serial myPort){
String temp=myPort.readStringUntil(‘\n’);
temp=trim(s);
if (temp != null){
int values[]=int(split(temp,’,’));
if (values.length==2){
xPos=(int)(values[0]);
yPos=(int)(values[1]);
}
}
println(xPos);
}
Flap like a Flappy Bird!
Have you ever wondered how the bird feels when it tirelessly flaps its wings through the never-ending tube maze? Look no further than this revolutionary interactive new flappy bird playing experience!
Step 1: Strap the Flappy-Bird Controller® tightly onto your hand like this:
Step 2: Flap away! Now you can get addicted to this stupid game all over again!
I made the Flappy-Bird Controller® with a tilt sensor wired in a serial circuit. The tilt censor only returns a 1 or a 0 and arduino sends that number to processing. Processing tracks the previous input and the bird only flaps when the previous number is 0 and the current input is 1. Below are my codes:
Arduino:
int inPin = 2; // the number of the input pin int reading; // the current reading from the input pin int previous = LOW; // the previous reading from the input pin // the following variables are long because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. long time = 0; // the last time the output pin was toggled long debounce = 50; // the debounce time, increase if the output flickers void setup() { Serial.begin(9600); pinMode(inPin, INPUT); } void loop() { int switchstate; reading = digitalRead(inPin); // If the switch changed, due to bounce or pressing... if (reading != previous) { // reset the debouncing timer time = millis(); } if ((millis() - time) > debounce) { // whatever the switch is at, its been there for a long time // so lets settle on it! switchstate = reading; } Serial.write(switchstate); // Save the last reading so we keep a running tally previous = reading; }
Processing:
main:
import processing.sound.*; import processing.serial.*; Serial myPort; int fly=0; int previous = 0 ; SoundFile hit; SoundFile die; SoundFile point; SoundFile wing; PImage backgroundImg; PImage img1; PImage img2; PImage img3; PImage img; PImage tube1; PImage tube2; int background =0; boolean state = false; boolean gameOver = false; float speed = 0; float gravity = 0.1; int score = 0; int hSpeed = 2; float x = 50; float y = 200; int tubeLength; Bird bird; Tube tube; ArrayList<Tube> tubeListTop; ArrayList<Tube> tubeListBot; void setup(){ size(600,600); printArray(Serial.list()); String portname=Serial.list()[9]; println(portname); myPort = new Serial(this,portname,9600); //size(1440,900); backgroundImg = loadImage("bg.png"); img1 = loadImage("upflap.png"); img2 = loadImage("midflap.png"); img3 = loadImage("downflap.png"); tube1 = loadImage("tube1.png"); tube2 =loadImage("tube2.png"); tubeListTop = new ArrayList<Tube>(); tubeListBot = new ArrayList<Tube>(); img = img3; hit = new SoundFile(this, "hit.wav"); die = new SoundFile(this, "die.wav"); point = new SoundFile(this,"point.wav"); wing = new SoundFile(this, "wing.wav"); for (int i=0; i<4;i++){ tubeLength =int(random(120,200)); tubeListTop.add(new Tube(660+180*i,0,60,tubeLength, hSpeed)); } for (int i=0; i<4;i++){ tubeLength =int(random(120,200)); tubeListBot.add(new Tube(660+180*i,505-tubeLength,60,tubeLength,hSpeed)); } } void draw(){ if(!gameOver){ println(fly+","+previous); img = img1; if(fly==1 && previous ==0){ img = img3; wing.play(); y = y-30; speed = speed *0.02; } previous = fly; image(backgroundImg,0,0); bird = new Bird(x, y); textSize(20); fill(0, 102, 153); text("FLIP YOUR WING TO FLY", 80,580); fill(255,0,0); text("Score: " + score, 450, 580); //if(keyPressed==true){ // use keyboard to move bird // if(key == 'w'){ // y--; // }else if(key== 'a'){ // x--; // }else if(key=='d'){ // x++; // }else if(key=='s'){ // y++; // } //} for(Tube tube:tubeListTop){ if(tube.locx<-60){ tube.setX(680); } tube.draw(); } for(Tube tube:tubeListBot){ if(tube.locx<-60){ tube.setX(680); } if (bird.locx == tube.locx){ score++; point.play(); } tube.drawInverse(); } }else{ // image(backgroundImg,0,0); //bird = new Bird(x, y); textSize(38); text("GAME OVER",180,270); textSize(16); text("restart the program to try again",170,290); } // Add speed to location. y = y + speed; // Add gravity to speed. speed = speed + gravity; if (y > height-123) { // Multiplying by -0.40 instead of -1 slows the object // down each time it bounces (by decreasing speed). // This is known as a "dampening" effect and is a more // realistic simulation of the real world (without it, // a ball would bounce forever). speed = speed * -0.40; y = height-123; } bird.draw(img); for(Tube tube:tubeListTop){ if(bird.onCollision(tube)&&!gameOver){ gameOver = true; hit.play(); delay(100); die.play(); } } for(Tube tube:tubeListBot){ if(bird.onCollision(tube)&&!gameOver){ gameOver = true; hit.play(); delay(100); die.play(); } } } //void keyPressed(){ //img = img1; //wing.play(); //} //void keyReleased(){ // y = y-30; // speed = speed *0.05; // img = img3; // } void serialEvent(Serial myPort){ fly=myPort.read(); }
Bird class:
class Bird{ float locx, locy; Bird(float x,float y){ locx = x; locy = y; } //void gravity(){ // // Add speed to location. // locy = locy + speed; //// Add gravity to speed. // speed = speed + gravity; //} void draw(PImage img ){ image(img,locx,locy); } boolean onCollision(Tube a) { // are the sides of one rectangle touching the other? if (locx + 36 >= a.locx && // r1 right edge past r2 left locx <= a.locx + a.xlen && // r1 left edge past r2 right locy + 26 >= a.locy && // r1 top edge past r2 bottom locy <= a.locy + a.ylen) { // r1 bottom edge past r2 top return true; } return false; } //http://www.jeffreythompson.org/collision-detection/rect-rect.php } class Tube{ int locx, locy, xlen, ylen, hSpeed; Tube(int x,int y, int xl, int yl, int hs){ locx = x; locy = y; xlen = xl; ylen = yl; hSpeed = hs; } void draw(){ image(tube1,locx,locy,xlen,ylen); locx -= hSpeed; } void drawInverse(){ image(tube2,locx,locy,xlen, ylen); locx -= hSpeed; } void setX(int x){ locx =x; } }
Physical Computing
I had no concept of what physical computing is prior to this semester. However, now I tend to find a lot of physical computing examples in my daily life. Even with my limited knowledge, I still try to figure out how would I make the dazzling lights show or big display screen with shiny letters. I also really like the idea of using technology to read human behaviours, analyze it and give feedback to hopefully improve the user experience. I am glad I have taken those IM classes this semester because I feel that my skills in programming now exists beyond just the screen of my computer but also in the real world. I am very proud that people can interact with some projects I have designed. The interaction between arts and technology truly makes physical computing interesting.
What Computing Means to Me
Honestly, before this class, I had always been aware of how important computing is, just never realized the nitty-bitty parts of it. The class made me appreciate all the things that really go into computing and all the things I interact with on a regular basis that I hadn’t really thought about before.
I think the most significant part for me was the intersection with the arts. It really interested me to see the possibilities of artistic creation through computing. For me, the way that the two forms intersected aligned with the type of work I find intriguing, as well as the type of work I could see myself exploring for my own artistic growth.
What does computing mean to me?
In terms of coming up with a definition of what computing means, I cannot yet give an answer for that I am still not sure the scope of computing. My previous understanding of computing has definitely expanded, however. There is a lot more to computing than I had originally thought, different languages, different programmes, different approaches to achieve different outcomes, or perhaps similar ones.
In contrast to my limited knowledge of the actual definition of computing, I do know my own definition of computing. It’s the long and arduous process that consists of me basically not knowing why certain lines of code work and why they do what they do, researching about them, learning about them, and then replicating them in my own projects. It’s a stressful task, but rewarding at the same time. I have realised that a lot of times, I need to go through each step slowly, thinking logically before diving head-first into the freezing cold water. In this case, the projects being the water. Perhaps I need to put on a cold-suit first, but before putting it on I need to find one. With this cold-suit, I am able to bear the task of swimming in the cold. The cold-suit is like the knowledge that I currently have and further need; perhaps sometimes I need additional research and help, some logical thinking and planning before I can approach the task at hand.
The process of learning how to compute, and thus being in this intro class, introduced me to a lot of pretty awesome people whom I have lots of pretty good banter (in my opinion). Computing has given me a really enjoyable (though stressful!) time so far.