Interaction Lab: Final Project (Professor Dan Mikesell)

Project Description & How it Works 

As mentioned in my Speed Dating Post, the journey to what eventually became my final project was a long one. However, I decided to make something a bit different from the justifiably popular game that many choose to make for their projects.

Inspired by GO GREEN Week! I wanted to make something that would encourage people to recycle and care more about the environment they’re living in because, honestly, we really only have one Earth. What’s interesting is the fact that people think they’re confident in determining what is recyclable. The fact is, however, there are a lot of ambiguities with categorizing a lot of items.

Therefore, I chose three everyday items to incorporate in my project:

  1. Plastic Water Bottle  — Recyclable 
  2. Milk Carton  — Possibly Recyclable (Ambiguous) 
  3. Ceramic Bowl, the kind they sell cheaply at Carrefour — Not Recyclable 

These three items, I noticed, were ones that people immediately conclude are recyclable. However, the reality is that each are all different with respect to whether or not you can as noted above.

My project attaches RFID tags (in the form of cards and a poker chip) to each of the three items above. When you scan the item against the reader, information pops up on the material the three different items are made up of. Before you scan, however, the window asks if you believe the item you chose is recyclable or not. Here, people will learn the truth behind each material (item).

Then, besides stating whether or not it is recyclable, information for each material says things like “if you don’t recycle this, then it will probably take up 450 years to decompose.” For the items that are not recyclable, it suggests re-using it for DIY projects or donating it to schools for art projects. Later in this documentation, I will show you the information labeled for each material. 

Project Materials 

  • Arduino & Processing
  • RFID reader
  • RFID tags/cards

RFID tags/card readers

RFID tags/card readers

13214878_1121069894600823_640657392_o

RFID reader attached to the Arduino

Sources Used in this Project

The sources listed here are places where I took facts/images used in the whole project.

http://hellogiggles.com/drake-hotline-bling/ (drake image)

https://imgflip.com/memegenerator (tool used to make my own meme)

http://www.postconsumers.com/education/how-long-does-it-take-a-plastic-bottle-to-biodegrade/ (how long it takes plastic to decompose) 

http://www.theguardian.com/lifeandstyle/2014/jul/16/plastic-poverty-pollution-china-recycling-dead-zone (image link to chinese woman with plastic bottles)

https://www.globalcitizen.org/en/content/the-dilemma-of-recycling-plastic-in-china/ (china facts about plastic)

http://recyclenation.com/2015/02/how-to-recycle-ceramic-and-porcelain-tiles (ceramic recycling facts)

http://www.plantcitygov.com/65/Recycling-Program-Information (blue recycling bin img)

http://www.clipartbest.com/clipart-yiop54yiE (blue recycling symbol img)

https://www.youtube.com/watch?v=7-AQ-In4Wos (recycling video that plays if you say you don’t want to recycle)

The Process of Making the Final: Problems & Solutions

In making the project, there were definitely a lot of moments that made my heart drop. The most obvious was the problem with the RFID reader. After having the one-one-one conversation with Professor Mikesell, he noted they only had the RFID reader with no tags, The most obvious solution to this was to just order them. However, the Professor luckily found more tags later .

Besides having no physical materials for a while, there was an issue with one of the readers not functioning anymore. This was probably the most frustrating situation out of the whole project because the Professor (and others I believe) spent time writing the code trying to get it to work and read the tags. Considering this happened two days before the final project was due, I think you can imagine how scared I was to have a broken reader. Then, it was a matter of trying to get the new RFID reader given to me to work.

Once that was solved, the next step was to get the serial communication working. With the help of the visiting Professor Dan Shiffman , this was solved! The RFID scanner had issues reading certain RFID numbers from the tags but he helped to fix the code so that it would read according those same numbers.

There were also some other technical difficulties such as problems with the video. In the home page, there are two options, “yes you want to save the Earth” and “no I don’t.” For the latter option a video pops up trying to convince you to recycle. For this, I had issues trying to get the video to go back to the home page (the page with the Drake meme). This was solved by creating a boolean and creating an if statement under key pressed so that showMovie = true

Quick Reflection 

After presenting my project, I received pretty interesting feedback in terms of where this project can go in the future. One of them included creating a website where each item can scan and it’ll bring them to that website. Besides having the same information on that website as my program, I could add on things like where you can recycle that item locally. From here, I believe that it’d be great if such a tool were implemented in the real world. That way, it can encourage people to recycle and make it fun doing so.

Project Video and Images 

Above is if the user says no, they wouldn’t want to recycle: a video pops up.

13199235_1121069851267494_6017657_o

 

the RFID readers were hidden behind the draw bar code

the RFID readers were hidden behind the draw bar code

the RFID not hidden so well here

the RFID not hidden so well here

info that pops up when a plastic water bottle is scanned

info that pops up when a plastic water bottle is scanned

ceramic material

stained carton

Processing Code

import processing.serial.*;

Serial myPort; // Create object from Serial class
int val; // Data received from the serial port

import processing.sound.*;
SoundFile file;

import processing.video.*;
Movie movie;

PImage photo;
PImage phototwo;
PImage photothree;

PImage photoCarton;
PImage photoPlastic;
PImage photoCeramic;

PFont f;
PFont j;

boolean drakePage = false;
boolean showInstruction = false;
boolean showMovie = false;
boolean askQuestion = false;
boolean scanPage = false;
boolean playMusic =false;

boolean milkCarton = false;
boolean plasticBottle= false;
boolean ceramic = false;

void setup() {
size(500, 375);

String portName = Serial.list()[2];
printArray(Serial.list());
myPort = new Serial(this, portName, 9600);

background(255);
drakePage =true;
photo = loadImage(“13hsur.jpg”);
phototwo = loadImage (“blue-recycling-image.jpg”);
photothree =loadImage (“recycling-bin-.jpg”);

photoCarton = loadImage (“stained carton.png”);
photoPlastic= loadImage (“Plastic Water Bottle.png”);
photoCeramic= loadImage (“ceramic material.png”);
f = createFont(“Century Gothic”, 12, true);
j = createFont(“Optima”, 26, true);
file = new SoundFile(this, “Stand By Me.mp3”);
movie= new Movie (this, “The Recycle Effect.mp4”);
file.play();

}

void serialEvent(Serial port) {
//int val = port.read();
//println(val);

String s = myPort.readStringUntil(char(3)); // read it and store it in val
if (s != null) {
//println(s);
String code = s.substring(1,s.length()-1);
println(code);
if (code.equals(“0000A19DAE92”)) {
println(“carton”);
milkCarton =true;
//background(255, 0, 0);
}
//println(s + ” ” + int(s.charAt(0)));
if (code.equals(“10008BC8B6E5”)) {
println(“plastic”);
plasticBottle =true;
}
if (code.equals(“0000A2EAA6EE”)) {
println(“ceramic”);
ceramic= true;
}
}
}

void draw() {
background(0);
image (photo, 0, 0);
fill(204, 0, 204);
rect (20, 150, 120, 60);

textFont(f, 12);

fill(255);
textSize(16);
text(“YES, let’s save”, 28, 175);
text(“the planet”, 36, 200);
fill(204, 0, 204);
rect (20, 230, 120, 60);
fill(255);
textSize(14);
text(“NAH, I’m ok with “, 25, 255);
text (“killing the EARTH”, 26, 275);

if (showInstruction) {
background(255);
image(phototwo, 20, 10);
image(photothree, 370, 220);

//textFont (f, 14);
fill(173, 129, 80);
rect(360, 200, 95, 40);
fill(0);
textSize(27);
text (“NEXT”, 375, 230);

fill(173, 129, 80);
textSize(18);
text (“INSTRUCTIONS”, 190, 90);
text (“Pick an item”, 200, 130);
text (“out of the three in front of you”, 125, 160);
text (“Press NEXT to Continue”, 150, 190);
//file.play();
}

if (askQuestion) {
background(0, 0, 205);
textFont (j, 24);
fill(0);
textSize(24);
text(“Do you think the chosen item is RECYCLABLE?”, 12, 60);

fill (0);
stroke(1);
rect(110, 100, 250, 50);
fill(255);
text(“DUH! OF COURSE”, 130, 135);

fill(0);
rect (110, 180, 250, 50);
fill(255);
text(“Maybe? Possibly?”, 140, 215);

fill(0);
rect (110, 260, 250, 50);
fill(255);
text (“Nope! Definitely Not”, 125, 290);
}

if (scanPage) {
background(255, 175, 175);
fill(173, 129, 80);
textSize(22);
text(“Now SCAN the item”, 145, 140);
text(“according to the wonderfully drawn”, 75, 170);
text(“serial number label”, 145, 200);

fill(255);
textSize(22);
text(“FIND OUT IF YOU GUESSED RIGHT”, 70, 240);
text(“&”, 230, 270);
text(“LEARN MORE ABOUT THE ITEM”, 80, 300);
}

if (milkCarton) {
photoCarton.resize(500, 375);
image(photoCarton, 0, 0);

fill (255, 204, 0);
rect (245, 350, 225, 20);
rect(20, 350, 225, 20);

fill(0,0, 102);
textFont(j, 16);
text(“PRESS ENTER to return HOME”, 30, 365);
text(“PRESS R to return to Scan Again”, 250, 365);
}

if (plasticBottle) {
photoPlastic.resize(500, 375);
image(photoPlastic, 0, 0);

fill (255, 204, 0);
rect (245, 350, 225, 20);
rect(20, 350, 225, 20);

fill(0,0, 102);
textFont(j, 16);
text(“PRESS ENTER to return HOME”, 30, 365);
text(“PRESS R to return to Scan Page”, 250, 365);
}

if (ceramic) {
photoCeramic.resize(500, 375);
image(photoCeramic, 0, 0);

fill (255, 204, 0);
rect (245, 350, 225, 20);
rect(20, 350, 225, 20);

fill(0,0, 102);
textFont(j, 16);
text(“PRESS ENTER to return HOME”, 30, 365);
text(“PRESS r to return to Scan Page”, 250, 365);
}

if (showMovie) {
image(movie, 0, 0, width, height);
fill(255);
textFont(f, 14);
text(“Press B to go back to orginal screen”, 10, 15);
}
}
void movieEvent(Movie m) {
m.read();
}

void mousePressed() {
if (mouseX>20 && mouseX<140 && mouseY>230 && mouseY<290) {

movie.play();
drakePage= false;
showMovie = true;
file.stop();
}
if (mouseX>20 && mouseX<140 && mouseY>150 && mouseY< 210) {
showInstruction = true;

}
if (mouseX>360 && mouseX<455 && mouseY>200 && mouseY<240) {
askQuestion = true;
}
if (askQuestion == true) {
if (mouseX> 110 && mouseX<360 && mouseY>100 && mouseY<150) {
scanPage = true;
}
if (mouseX>110 && mouseX<360 & mouseY>180 && mouseY<230) {
scanPage= true;
}
if (mouseX>110 && mouseX<360 && mouseY>260 && mouseY<310){
scanPage= true;
}
}
}

void keyPressed() {
//if (key == CODED) {
println(key);
if (key == ‘b’) {
showMovie = false;
movie.pause();
movie.jump(0);
}
//if (key == ‘r’){
// drakePage= true;
//}
}

Arduino Code
#include <SoftwareSerial.h>

SoftwareSerial SoftSerial(2, 3);
unsigned char buffer[64]; // buffer array for data receive over serial port
int count=0; // counter for buffer array

void setup()
{
SoftSerial.begin(9600); // the SoftSerial baud rate
Serial.begin(9600); // the Serial port of Arduino baud rate.
}

void loop()
{
if (SoftSerial.available()) // if date is coming from software serial port ==> data is coming from SoftSerial shield
{
while(SoftSerial.available()) // reading data into char array
{
buffer[count++]=SoftSerial.read(); // writing data into array
if(count == 64)break;
}
Serial.write(buffer,count); // if no data transmission ends, write buffer to hardware serial port
clearBufferArray(); // call clearBufferArray function to clear the stored data from the array
count = 0; // set counter of while loop to zero
}
if (Serial.available()) // if data is available on hardware serial port ==> data is coming from PC or notebook
SoftSerial.write(Serial.read()); // write it to the SoftSerial shield
}
void clearBufferArray() // function to clear buffer array
{
for (int i=0; i<count;i++)
{
buffer[i]=NULL;
} // clear all index of array with command NULL
}

 

Final Project: Speed Dating (Dan Mikesell)

For this class, our Professor reminded us to come prepared with an idea for our final project. The idea I had initially prepared changed quite a bit (this is most likely an understatement) after discussing it with my classmates.

The Initial Idea: My first idea was inspired by a project I stumbled upon online. This project creates a “smart trash can” that would automatically open the trash can using an ultrasonic sensor and a servo. Afterwards, I wasn’t sure how to add on or modify this idea to make it into my own. One of the possibilities was to make a kind of game that kept track of whether or not you get a crumpled ball of paper in the trashcan. Interestingly enough, this was inspired by my midterm project which was the basketball-themed Processing project.

After Speed Dating: As I talked through this project, I think many noticed that I was pretty attached to the idea of the trash can and less so about the gaming aspect. So, eventually this idea changed from trash to recycling. This was very much due to the fact that Go Green Week! had just ended right before the speed dating class. The idea at this point was to use a sensor to sense recyclable material. Now the question had shifted to: Which sensor? and How to do it? Some recommendations included using a light sensor or a density sensor, if IMA equip had it. Two people had in fact suggested a light sensor to do so.

So, now that my project was more concrete, the only thing I had left to figure out was the HOW question. This, of course, was later solved when I had my one-on-one discussion with the Professor.

My take away points:

  1. Goal of the project was to learn AND encourage recycling
  2. Sensors I could use: Light sensor (purposely use certain colored plastic, glass, metals, and have it tell you information based on the material)
  3. If a material did not have a clear answer as to whether or not it can be recycled, a voice or sound was suggested to make it more appealing and funny.

Although I didn’t get to talk to every single group due to the arrangement of the whole speed dating game, I am 100% glad that my idea had improved so much and I was more confident for the future of my project.

After One-on-One Conversation with the Professor:

Through this meeting, I was able to answer some questions about how to go about realizing my project.

  1. The Sensor Question: The Professor suggested using an RFID reader and tags. These materials, as he explained work like how our NYU ID cards work as they can scan and read information. For example, when we’re paying for the food and whatnot, the card tells you how much money you have left.
  2. Further Recommendations: He also recommended that I make an image of the information that I want to display once the scanner scans.

Interaction Lab 10: Working with Video (Dan Mikesell)

For this lab, we were required to work with video and/or computer vision. I decided to work with video in Processing because I wanted to continue working on the exercise the Professor had us do on the day before. I took a video from my computer — a personal vlog I recorded when I visited Namsan Tower in Korea. Unfortunately, the video was taken as portrait rather than landscape. Therefore, I asked if I could change the orientation on Processing, but it seems like you can’t if the video was produced/recorded that way. Ultimately, the video showed up sideways as seen in the clip below. In order to experiment with the different functions of video, I decided to play with the scratch example. I wanted the video to play and pause once I pressed any key on the keyboard. Later, I wanted the video to play at random parts of the video once the mouse was pressed at any point. When I tried to incorporate these features on Processing, I had difficulty doing so and only then after a few tries did I understand the difference between movie.loop and movie.play();  movie.jump(0);movie.pause(); as demonstrated by Antonius. The former makes the video go back to the beginning whereas the latter has it play once as you while you are able to manipulate the play and pause features. Actually, I only had a bit of time left to play with the features because Processing wouldn’t register my video. I had to restart my computer in the end to get it to work again until I used another video.

Interaction Lab 10 Video (SEE VIDEO)

import processing.video.*;

Movie movie;

void setup(){

size(640,360);

background(0);

 movie= new Movie (this, “IMG_0559.mov”);

  movie.play();

 movie.jump(0);

 movie.pause();

//  movie.loop(); 

}

void movieEvent(Movie m){

 m.read();

}

void draw(){

 if (movie.available()) {

   movie.read();

 }

 image(movie, 0, 0, width, height);

}

void mousePressed(){

 movie.pause();

 movie.jump(random(movie.duration()));

 movie.play();

}

Interaction Lab 9: Working with Images/Audio (Dan Mikesell)

This week, we were asked to work with images and audio and somehow incorporate some interactivity to it. I used the example in the Processing library as a guide to play a Beyonce song, “Drunk in Love.”  Additionally, the wave forms are shown as the song goes on. As long as a key is pressed, the song plays and pauses. Furthermore, I added an image of Beyonce to incorporate the visual required for the lab. I went and played around with the transparency example and added that on top of the audio. The following is the result of playing around with these great features. I think working with things like video, image, and audio are the most fun I’ve had so far out of all the labs. Below you will find the code for the lab. 

Lab 9 Image 1

Interaction Lab 9 (SEE VIDEO)

import ddf.minim.*;

Minim minim;
AudioPlayer player;

PImage img;
float offset = 0;
float easing = 0.05;

void setup()
{
size(500, 500, P3D);
img = loadImage(“beyonce.jpg”);

// we pass this to Minim so that it can load files from the data directory
minim = new Minim(this);

// loadFile will look in all the same places as loadImage does.
// this means you can find files that are in the data folder and the
// sketch folder. you can also pass an absolute path, or a URL.
player = minim.loadFile(“Drunk In Love.mp3”);
player.rewind();
}

void draw()
{
background(0);
stroke(255);
image (img, 100, 200);
float dx = (mouseX-img.width/2) – offset;
offset += dx * easing;
tint(255, 127); // Display at half opacity
image(img, offset, 0);
// draw the waveforms
// the values returned by left.get() and right.get() will be between -1 and 1,
// so we need to scale them up to see the waveform
// note that if the file is MONO, left.get() and right.get() will return the same value
for(int i = 0; i < player.bufferSize() – 1; i++)
{
float x1 = map( i, 0, player.bufferSize(), 0, width );
float x2 = map( i+1, 0, player.bufferSize(), 0, width );
line( x1, 50 + player.left.get(i)*50, x2, 50 + player.left.get(i+1)*50 );
line( x1, 150 + player.right.get(i)*50, x2, 150 + player.right.get(i+1)*50 );
}

// draw a line to show where in the song playback is currently located
float posx = map(player.position(), 0, player.length(), 0, width);
stroke(200,100,0);
line(posx, 0, posx, height);

if ( player.isPlaying() )
{
text(“Press any key to pause playback.”, 10, 20 );
}
else
{
text(“Press any key to start playback.”, 10, 20 );
}
}
void keyPressed()
{
if ( player.isPlaying() )
{
player.pause();
}
// if the player is at the end of the file,
// we have to rewind it before telling it to play again
else if ( player.position() == player.length() )
{
player.rewind();
player.play();
}
else
{
player.play();
}
}

Interaction Lab 8: Working with Motors (Dan Mikesell)

In this lab, we began implementing what we learned during the lectures this week surrounding motors. Out of the two circuits we had the option to build, Efae (Royale) and I chose the one advertised as the “more difficult one,” or the bipolar stepper motor with an L298 H-bridge. We were up for the challenge and it seemed like it was going to be more fun than the easier circuit. Fortunately, we found that it wasn’t hard at all. Below, you will find the assignment that we completed. 

stepper

We just had to make sure we remembered and labeled everything according to the data sheet provided on the IMA website. It also helped that Antonius gave us tips on how to read the circuit diagram correctly before we began putting the puzzle pieces together (aka all the wiring) so we wouldn’t make the mistakes it seemed others had made before. Additionally, we had to guess and check which wires from the stepper produced the most resistance. Once we completed that step, we also had to make sure we placed it on the right side of the H-bridge. I can say that this lab was the most interesting in my opinion and the most relaxing. It was like a puzzle and it went so smooth. Afterwards, once we added some code to Arduino, we paired up with Jason and Anluz . We attached our own steppers to a contraption that allowed them to draw on a piece of paper. Though we found that we had to hold the paper down while the motors were going, I thought it was so cool that we could change the speed of the steppers individually and the outcome of the change in speed was that it drew a bit more accurately.

13016625_1102816006426212_126469343_o

 

12986346_1102815993092880_525717143_o

 

 

 

Interaction Lab 7: Laser Cutting and 3D Modeling Design (Dan Mikesell)

For today’s lab, we had to laser cut our drawing we made using Adobe Illustrator on Thursday’s class. Before Friday’s class, however, the Professor noted that I had not distinguished between what I wanted etched and what I wanted cut because the stroke color on my drawing was all black. In order to fix this, I made the actual drawing red while the outline of the keychain and the hole was black. For my keychain design, I drew Doodlebob, a character from one episode of Spongebob Squarepants. Below, you will find the inspiration behind my keychain.

Watch the episode if you haven't! It's hilarious!

Watch the episode if you haven’t! It’s hilarious!

Drawing before the revisions

My drawing before the revision

The design that went to the laser cutter

The design that went to the laser cutter with Doodlebob’s signature catchphrase

Another problem I (and our whole class) encountered was the issue of changing the cutting measurement from 0.1 inch to 0.1 point. Our class had used a different unit of measurement but this was easily changed on Adobe to match the laser cutter settings Antonius used during the lab.

My drawing can be seen on the right as it goes to the laser cutter

My drawing can be seen on the screen right before it goes to the laser cutter

the final product!

the final product!

I hoped that Doodlebob’s features (mouth and nose) would’ve turned out better than they did. I forgot to consider the darkness of Doodlebob’s entirety relative to the color of his features. I also really liked the material I chose for this keychain.

Afterwards, while we were waiting for everyone else to get their design from the laser cutter, we played with 3D design using the websites suggested in class. Like many, I decided to use Tinkercad and just like the Professor said in class, it was harder to use without the mouse. However, I received help from the programmers that came to visit and who better to teach others how to use it than the people who programmed it themselves. Below you will see the design. As for any challenges, I think just figuring out how to align things properly such as the plaque to the ring and trying to using an image online.

Screen Shot 2016-04-10 at 8.59.39 PM

Screen Shot 2016-04-10 at 8.59.17 PM

I

 

Interaction Lab: Midterm Project (Dan Mikesell)

Group Member: Myself (Shirley Ariza)

I had a hard time initially coming up with an idea for this midterm project that I was completely confident in. After deciding that I wanted to play with the idea of a fortune teller, I proposed to the professor that I would somehow use the idea of a paper fortune teller most of us played with as kids. However, I spent a few days at my drawing board (more like my little notebook) and I felt that it was imperative to move on since the deadline for the midterm project was quickly approaching. I haven’t given up on this project and I am still working on it on my own time. Here’s a little of what I’ve done with respect to that.

Midterm Attempt 1(LATEST VIDEO)

Midterm Attempt  (EARLIEST Form of PROJECT ABOVE)

Midterm Initial Project

Then, I came up with another idea: basketball. After seeing updates of all the March Madness games on my feed, I thought it was more feasible to work with this idea given the limited amount of time. I looked online to see if there was anything I could work with and give it my own spin. Turns out, I found some pretty useful sketches on OpenProcessing that I’d like to give credit to.

Midterm Inspiration

The rim and court idea

http://www.openprocessing.org/sketch/129 & http://openprocessing.org/sketch/324242

With the help of Susan (IMA student worker), she helped me figure out how to make my ball bounce and fix the speed the way I wanted it to work. The court and net in particular took a hefty amount of time to figure out because I had to figure out the coordinates in order to make it all even and proportionate. Below you will also find some of my calculations before trying to draw it on Processing. As for the net, I’m not sure if there was an easier to draw it than how I actually did it, but I tried relying on what I learned in class to make the shape. Therefore, I ended up drawing individual lines for the net and the for the court (the penalty lines, etc) in order to make it more realistic. The most challenging part for me was, well, the math behind it all considering the fact that I tried to make the court at an angle (point of view shot) since the person playing basketball is supposed to be standing right at the center of the court. Another challenge I faced was making the ball bounce in a way that wasn’t so erratic. Initially, the ball’s speed would change so that it kept going higher and higher. However, with the help of Moon, one of the IMA fellows, he helped me fix it by changing the frame rate. Although it did help so that it’s not so crazily bouncing like before, I still that I could find a way to improve it for my final.

Midterm Sketch#1 Midterm Sketch #2

Trying to figure out ball bounce equation

Trying to figure out ball bounce equation

As for the final, I am planning on making the basket move back and forth so that the player can try to shoot the ball in the basket. Additionally, just as it was suggested during my presentation, I also want to include a sound of the crowd cheering when the player makes the basket and a “boo!” sound whenever the player doesn’t make it in. There will also be a timer ticking loudly to make the game more nerve-wrecking. With respect to somehow incorporating the Arduino, I’m hoping to use a sensor that will make it more interactive so that my game will work similar to the Wii.

In an ideal world, I would have liked to accomplish all that I listed above for the final, but I knew that it was impossible when my initial fortune teller idea couldn’t be realized in the time that I wanted it to. However, I definitely learned that it’s important to commit to an idea faster and try to understand my own limits since I’m only just a beginner in Processing. To be honest, I felt that it was already a challenge to take on this midterm project by myself, but I felt that I wouldn’t learn if I relied too much on someone else. When listening to other people’s projects, I felt that it was important for me to ask for more help in order to improve my project.

 

float rimX;

float rimY;

float d=100;

float ballX=400;

float ballY=800;

float speedY=2;

PImage bg;

 

void setup() {

 size(800, 800);

 bg = loadImage(“basketballcrowd.jpg”);

 

 rimX = 400;

 rimY = 180;

}

 

void draw() {

 background(bg);  

 

 //court

 smooth();

 fill(200, 100, 0);

 stroke(255);

 strokeWeight(2);

 quad(0, 800, 250, 400, 550, 400, 800, 800);

 

 //court detail

 //fill(200,100,0);

 noFill();

 stroke(255);

 strokeWeight(3);

 arc(400, 800, 275, 275, PI, TWO_PI);

 line(300, 401, 250, 550);

 line(500, 401, 550, 550);

 arc(400, 550, 300, 150, 0, PI);

 ellipse(400, 550, 150, 100);// efae’s suggestion

 quad(350, 400, 325, 550, 475, 550, 450, 400);

 quad(340, 400, 310, 550, 490, 550, 460, 400);

 

 //hoop

 fill(255);

 stroke(200, 0, 0);

 strokeWeight(2);

 //quad(245,80,245,0,255,0,255,80);

 quad(395, 175, 395, 0, 405, 0, 405, 175);

 

 //backboard

 fill(255);

 stroke(200, 0, 0);

 strokeWeight(3);

 //quad(175,150,175,50,325,50,325,150);

 quad(310, 175, 310, 50, 490, 50, 490, 175);

 

 //backboard square

 fill(255);

 stroke(200, 0, 0);

 strokeWeight(3);

 //quad(225,140,225,100,275,100,275,140);

 quad(370, 165, 370, 115, 430, 115, 430, 165);

 

 //rim box

 fill(200, 0, 0);

 stroke(200, 0, 0);

 //quad(245,150,245,140,255,140,255,150);

 quad(390, 175, 390, 165, 410, 165, 410, 175);

 

 //rim

 noFill();

 stroke(200, 0, 0);

 strokeWeight(5);

 ellipse(rimX, rimY, 75, 15);

 

 

 //net

 noFill();

 stroke(255);

 strokeWeight(1);

 line(362, 185, 370, 240);

 line(436, 185, 430, 240);

 line(436, 185, 370, 240);

 line(362, 185, 430, 240);

 line(390, 240, 434, 203);

 line(410, 240, 432, 221);

 line(367, 221, 410, 185);

 line(364, 203, 386, 185);

 line(367, 221, 390, 240);

 line(364, 203, 410, 240);

 line(386, 185, 432, 221);

 line(410, 185, 434, 203);

//basketball

 fill(255);

 ellipse(ballX, ballY, d, d);

 ballY=ballY+speedY;

 speedY = speedY + 0.5;

 if (ballY > height – d) {

   // set the position to be on the floor

   ballY = height – d;

   // and make the y speed 90% of what it was,

   // but in the opposite direction

   speedY = speedY * -0.9;

   //switch the direction

   //speedY = speedY;

 } else if (ballY <= 0) {

   // if the ball hits the top,

   // make it bounce off

   speedY = -speedY;

 }

 //add speed to the ball’s

 ballY = ballY + speedY;

 //while(d>=30){

 //  d=d-1;

  pushStyle();

 fill(255);

 text( frameRate, 10,20);

 popStyle();

}

Midterm Project Photo

Midterm Project Video

 

Interaction Lab 6: Serial Communication (Dan Mikesell)

In this lab, we experimented with what we learned in class this week: serial communication between Arduino and Processing. I worked on this lab with Efae (Royale) and Matteo. We planned to incorporate one of the examples we were shown in class where a horizontal line moved up and down the screen. At the same time, we also wanted to use the distance sensor so that when we placed our hand closer to the sensor, the line would move and down accordingly. We had a hard time trying to combine all of this together, but with the help of Matt and Antonius, we fixed our code accordingly. Before we asked for help, we had a lot of unnecessary parts of the original code from the example that prevented it from working properly. Also, we learned from Antonius about a new tool called map. By using map, we were able to get it to work a lot smoother than before when the line would move erratically. To make it look a bit better, we adjusted the stroke weight to make it perfectly clear that the sensor was working.

Processing Code 

int lineY;

import processing.serial.*;

Serial myPort;

void setup() {

 size (500, 500);  

 myPort=new Serial(this, Serial.list()[0], 9600);

}   

void draw() {   

 while (myPort.available() > 0) {

   int inByte= myPort.read();

   println(inByte);

   //map values    

   lineY=int(map(inByte,0,255,height,0));

 }

 background(0);

 stroke(255);

 strokeWeight(6);

 line(0, lineY, width, lineY);

}
Once we figured out the Processing part, we moved on to write the code for Arduino. It was pretty straightforward since most of our time was spent figuring out Processing.

Arduino Code

int val=0;

void setup(){

 Serial.begin(9600);

}

 

void loop(){

 // analog in is 10 bits -1023

 val=analogRead(0);

 //serial write is 1 byte (8 bits)- 256

 Serial.write(val/4);

 delay(75);

}

Lab 6 Photo 1

Lab 6 Photo 2

Lab 6 Photo 3

Lab 6 VIDEO

Interaction Lab 5: Working with Sensors (Dan Mikesell)

For this week’s exercise, we were required to work with one of the five sensors offered: moisture, vibration, distance, ultrasonic ranger, or 3-axis accelerometer. My partner Wenqian Hu and I decided to work with the vibration sensor. The instructions had us attach our sensor to the Arduino and use the data from it to turn an output of our choosing (Servo motor, LEDs, Buzzer) on and off. We chose to use an LED in addition to jumper cables, resistor 220R, and the vibration sensor. We followed the same instructions listed on the Project 7 Card (see Lab 1) where it shows you how to create a circuit that detects vibration. However, we had to change the code to let Arduino know which output we were using and as you can see below, we used pin 13. We came up with the following code.

void setup() {

 // initialize serial communication at 9600 bits per second:

 Serial.begin(9600);

 pinMode(13, OUTPUT);

}

 

void loop() {

 int val = analogRead(A0);

 // print out the value you read:

 Serial.println(val);

 delay(1);        // delay in between reads for stability

 if (val > 0) {

   digitalWrite(13, HIGH);

   delay(1000);

   digitalWrite(13, LOW);

   delay(1000);

 }

}

Overall, we were successful except for a few problems with the Arduino program not responding well during class. My partner and I completed our goal just in time before class ended and it was fun to see the numbers reflect how hard we pressed down on our sensor.

IMG_0388

IMG_0389

IMG_0390