Guille’s Midterm Poyect: Electronic dice !!

So i decided to make a electronic dice for my midterm because i wanted to start working with led’s for my final. I started looking online for various methods of developing my dice and found a few interesting websites that help me lead my self (www.instructables.com) and finally started constructing my dice. I attached the shield to my arduino and taped the breadboard on top of it and then just started connecting a lot of wires here and there and finally installed the leds !

After that there was a switch that had to be put in place for the dice to work each time you rolled it but i decided to change that up for another type of switch and thought about the motion sensor switch and just replaced the normal switch. then to make my experiment portable i decided to add the 6 battery pack to my arduino and it turned out perfectly!

the items needed is very basic it includes:

Arduino or a clone ( I’m using a protoshield but a breadboard will work the same way)
11 Jumper Wires (or stripped wires in order to make connections on a breadboard)
7 Resistors (I used 330ohms) (ORANGE)(ORANGE)(BROWN)(GOLD)
7 LEDs ( I used green)
1 tactile switch or motions sensor (I used a motion sensor)

Photo on 10-21-13 at 5.59 PM

Fred’s Midterm Project: Virtual Color Mixer

Hello, my name is Fred Wu and today I want to introduce my mid-term project: virtual color mixer. Basically, it needs three potentiometers to control RGB colors, and what I’ve done is to program Arduino so that it can output  the value according to the resistance. By using the serial fuction in Processing, we can vividly demonstrate how the values change.IMG_0508 IMG_0509

Codes:

const int redPin = A0;      // sensor to control red color

const int greenPin = A1;    // sensor to control green color

const int bluePin = A2;     // sensor to control blue color

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

void loop() {    Serial.print(analogRead(redPin));

Serial.print(“,”);

Serial.print(analogRead(greenPin));

Serial.print(“,”);

Serial.println(analogRead(bluePin));

}

Processing code

//  This example code is in the public domain.

import processing.serial.*;

float redValue = 0;        // red value

float greenValue = 0;      // green value

float blueValue = 0;       // blue value

Serial myPort;

void setup() {

size(200, 200);

// List all the available serial ports

println(Serial.list());

// I know that the first port in the serial list on my mac

// is always my  Arduino, so I open Serial.list()[0].

// Open whatever port is the one you’re using.

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

// don’t generate a serialEvent() unless you get a newline character:

myPort.bufferUntil(‘\n’);

}

void draw() {

// set the background color with the color values:

background(redValue, greenValue, blueValue);

}

void serialEvent(Serial myPort) {

// get the ASCII string:

String inString = myPort.readStringUntil(‘\n’);

if (inString != null) {

// trim off any whitespace:

inString = trim(inString);

// split the string on the commas and convert the

// resulting substrings into an integer array:

float[] colors = float(split(inString, “,”));

// if the array has at least three elements, you know

// you got the whole thing.  Put the numbers in the

// color variables:

if (colors.length >=3) {

// map them to the range 0-255:

redValue = map(colors[0],978, 1023, 0, 255);

greenValue = map(colors[1], 978, 1023, 0, 255);

blueValue = map(colors[2],978, 1023, 0, 255);

}

}

}

*/

 

 

A busker playing erhu

 

We started the assignment with recording the sound of the background music (played with erhu), the wind  stimulated by Lee, and the people talking. Then we edited with Audacity. The problem existed in the volume of the background music, the convergence of different sounds, and the logic of the story. To revise the audio, we added the sound of coins thrown into the bowl, adjusted the timing of the wind and the dialogue. And, there comes our final audio!

( The wav from is not permitted, so we send the sound by e-mail )

Team:  Jane, Yulanda, Stalla, Lee

Midterm Project Documentation: Final (Kevin & Max)

So for our midterm project, we originally wanted to make the Mao Statue on a skateboard dodge obstacles on a rolling screen, with randomized objects coming out of the side. However we found that with our limited understanding of processing, that it would prove to be far-fetched to attempt to use a rendered image of the Mao Statue remain on the skateboard, which was made out of objects on the processing. The mouseX and mouseY functions were just too confusing for us to figure out. So scrapping the Mao idea, we decided instead to use a small Bart Simpson figure as our cursor, movable by the mouse functions. From there we found an image online of a bird’s eye view of a street and used that as the background.
Our goal with this movable Bart figure would be to create a little game with obstacles dropping out from random places from the top of the screen and the objective would be to dodge the objects without being hit. So after photoshopping a few images of Kevin’s and Max’s face, we created the objects. Using the x = function(width) in the void setup portion of the code to have the objects appear in different places every time we start the code. We gave each of the objects different dropping speeds so the user would have a more difficult time avoiding the objects. We also continued the scrolling of the objects by making them repeat their course of action once they rolled to the bottom of the screen. So what we have is a Bart figure, controlled by the user, attempting to dodge the falling objects. Looks like this:
Capture

Failures:

We were disappointed by several things in our midterm project. The first thing had to be the randomizing function. When initiating the objects to have randomized dropping places in the void setup, we understood that the objects would have different falling places every time the code started. However we wanted the objects to continually have different falling places once they finished the run through the screen. So putting the random x function again in the void draw section to redraw the images only created wonky images that bounced off the left and right sides of the screen, without stopping. So that left the objects continually falling from the same place they started at each time the code was started. The second and probably the most frustrating thing that we had to deal with was a lack of a hit detection system that would make the Bart figure disappear when the user failed to avoid the object. However, we were totally unsure how to accomplish this. We tried created an if statement that would make the Bart figure false if the object touched mouseX / mouseY ‘s position, but that didn’t turn out correctly. So those are two things we wish to improve on when we try to recreate a game in the future.

CODE:

// declaring variables for images loaded
PImage bg, bart, mine1, mine2, mine3, max, space;
// declaring variables for animation
float x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, SpeedY1, SpeedY2, SpeedY3, SpeedY4, SpeedY5, w, h;

 
void setup() {
size(412, 600);
smooth();

// loading street background
bg = loadImage(“Sidewalk.jpg”);
noCursor();

//loading skateboard and faces
bart = loadImage(“simp.png”);
mine1 = loadImage(“mine.png”);
mine2 = loadImage(“mine.png”);
mine3 = loadImage(“mine.png”);
max = loadImage(“Beard.png”);
space= loadImage(“spacebeard.png”);

// initiate drop speed
SpeedY1 = 5;
SpeedY2 = 3;
SpeedY3 = 2.1;
SpeedY4 = 4;
SpeedY5 = 6;

x1 = random(width);
x2 = random(width);
x3 = random(width);
x4 = random(width);
x5 = random(width);
}

void draw() {
// redrawing background to prevent dragging
background(bg);
noFill();

// drawing animation of bart
image(bart, mouseX, mouseY);

//drawing falling Beard(s)
y4=y4+SpeedY4;
image(max, x4, y4 – 500);

//drawing falling spacebeard(s)
y5=y5+SpeedY5;
image(space, x5, y5 – 200);

// drawing falling Kevin(s)
// x = random(width);
y1=y1+SpeedY1;
image(mine1, x1, y1);
y2=y2+SpeedY2;
image(mine2, x2, y2);
y3=y3+SpeedY3;
image(mine3, x3, y3);

if(y1 >= height) {
y1 = 0;
}
if(y2 >= height) {
y2 = 0;
}
if(y3 >= height) {
y3 = 0;
}
if(y4 >= 1100) {
y4 = -500;
}
if(y5 >= 800) {
y5 = -200;
}

}

Xiaoyue’s AWESOME Midterm Project “Rhythmania”

I wish for a music player that plays music that matches the way you dance. For this midterm project I created a pedal so that the computer can  choose the  music to play according to the beats you step on the pedal.

The first problem I had to tackle was to calculate the beat. I needed something like a timer. so I thought of letting a line going from the left to the right of the screen. I could record the positions of the line when the pedal is stomped on, and compare the differences of the positions.

I wanted to add a little something that would help the user understand what the project is doing by leaving a line on the screen each time he or she steps on pedal. But it gets confusing as the line restarts from the left every time it reaches the right. I put background() in draw(), but then the line didn’t leave a mark on the screen at all. Then Matt suggested that I should think of drawing the lines every time the draw() runs. I tried the “for” loop and it worked!

A very difficult thing for me was to connect Arduino with Processing. How does Processing receive data from Arduino? I tried Firmata but the codes were complicated. Matt told me that he very often used Serial Port to send and receive information between programs and we found an example code.  There was some problem with what sort of data processing is looking for, but by trying out the different possibilities, I adjusted the example code to my project.

I didn’t know how to use Processing to play music. Vivian told me there was something called minim and she helped me so much with where to look for resources I could use.

Then a crisis occured because the program reported that there was not enough space. I was inspired by Matt talking about defining a functon by ourselves instead of using draw(), which occupied so much space. I dragged a function out of draw(). Problem solved.

Also, one particular headache I had was that as I stepped on the mat, there was always a period of duration, so the line sometimes left several lines closely together at one time, which totally messed up my beat calculation. Matt hinted that I should have a true or false value to work like a switch. This was so helpful. I thought about it and used boolean; it worked perfectly!

I broke the project into small pieces and finished them one at a time. Then I fused them together and made adjustments. I feel this is a very efficient and less scary way of doing projects!

There are so many things to talk about! I have different versions of my music players. I have my primitive ones, which need to be restarted if you want them to play another song before one song ends. I have my lying ones which works fine if and only if the line is moving in its first round (math problem). I have my noisy ones which sometimes play several songs at the same time. I have my processing one, which does not require the Arduino part at all to run well( but of course the important experience of the user is missing). I have my tough one, which can be very hard to control with Arduino because of delays.

Everything needed adjustments and improvements all the time, as I got closer to my expectation step by step.  A good amount of math-related thinking was involved in my program. Now my program plays music smoothly, having no trouble switching from one song to another; the music can be stopped if you step on the pedal after playing the music for a long time or you stomp on the pedal too quickly. The lines are clear indicators. I love my project very much. I didn’t know much about Processing or Arduino and I still don’t, but trying was very important. Just trying out different possibilities and exercising new things helped me learn a great deal and become much more comfortable with Processing & Arduino. My heartfelt thanks go to dear Matt, dear Marianne and dear Vivian who inspired me and supported me. I strongly recommend my fellow students to communicate more with professors and teachers because students can learn so much this way.

My project can be in so many ways improved and enhanced. My hope right now is that I can continue and create what I wish for (stated at the beginning of this documentation).

Note: Just before presentation a fellow student accidentally kicked over my Arduino and broke the force sensor. I had to take the force sensor off the circuit and use the naked ends of the wire to control the circuit and play music. So what I presented in real was a music player controlled by “clapping”(not even so much as clapping) rather than stomping.

Shirley’s Midterm Project ヾ(´∀`o)

Untitled-1

 

At first, I had couples of ideas about my midterm project. I tried some of them, but they seemed to be a tough challenge to a beginner as me.

Therefore, I started with some simple shapes and tried to combine my project with some photoshop and illustrator stuff, which I know pretty well. I used them to creat a background and Shanghai’s skyline. It turned out to be a good idea and made my work much easier.

All the changes in my work, such as the location of the sun and the colors, are controlled by mouseX. It’s really not easy to compute everything with a single variable , especially the location of the sun.

Basically, I just played with codes. I didn’t have a clear plan. I just kept adding and testing my ideas to the project. That is why my codes are totally a mess. I made many mistakes, but those mistakes always surprised me. They made my work even nicer than I expected.

My codes:

 

PImage backgroundImg;
PShape shanghai;
PShape shanghailine;
PFont font1;
PFont font2;
float radius;
float location=-radius;
float s=30;

void setup() {
size(1200, 650);
smooth();
noCursor();
backgroundImg=loadImage(“background.jpg”);
shanghai=loadShape(“shanghai.svg”);
shanghailine=loadShape(“shanghailine.svg”);
font1=loadFont(“DilleniaUPC-48.vlw”);
font2=loadFont(“FangSong-48.vlw”);
}

void draw() {
//background
image(backgroundImg, 0, 0);//00

//hikari
int morning=floor(map(mouseX, 0, 600, 255, 0));
int afternoon=floor(map(mouseX, 601, 1200, 0, 255));
noStroke();
if (mouseX<=300) {
fill(#FF6A40, morning-50);
}
if (mouseX>=902) {
fill(#FF6A40, afternoon-100);
}
else {
noFill();
}
rect(0, 0, 1200, 500);

//skyline
shape(shanghai, 280, 160);

//light
int morning2=floor(map(mouseX, 0, 600, 255, 0));
int afternoon2=floor(map(mouseX, 601, 1200, 0, 255));
noStroke();
if (mouseX<=600) {
fill(0, 0, 0, morning2);
}
else {
fill(0, 0, 0, afternoon2);
}
rect(0, 0, 1200, 500);

//reference track
noFill();
noStroke();
float rtx=width/2;
float rty=650;
ellipse(rtx, rty, 1000, 1000);

//sun
noStroke();
float sx=mouseX;
float sy=700-sqrt(250000-sq(sx-rtx));

fill(#FFEAA2, 100);
ellipse(sx, sy, 65, 65);
fill(#FCFFA2, 100);
ellipse(sx, sy, 75, 75);

fill(255);
ellipse(sx, sy, 50, 50);
if (mouseX<=298) {
fill(#FC3300, morning*2+20);
}
if (mouseX>=902) {
fill(#FF3300, afternoon*2+20);
}
ellipse(sx, sy, 50, 50);

//line
if (mouseX<=300 || mouseX>=900) {
shape(shanghailine, 280, 160);
}

//rings and stars
if (mouseX>=100 && mouseX<1100 && mousePressed) {

noStroke();
fill(#FFFBA7, 150);
ellipse((sx+2*600)/3, (sy+4*500)/5, 20, 20);
fill(#FFBE89, 150);
ellipse((sx+6*600)/7, (sy+500)/2, 10, 10);

noFill();
stroke(255, 170);
ellipse((sx+3*600)/4, (sy+500)/2, 20, 20);
stroke(#FFBE89, 190);
ellipse((sx+600)/2, (2*sy+500)/3, 70, 70);
stroke(#FFF417, 130);
ellipse(sx, sy, 120, 120);
}
if (mouseX<100 || mouseX>=1100) {
noStroke();
fill(floor(random(150, 255)), floor(random(150, 255)), floor(random(150, 255)));
ellipse(random(0, 1200), random(0, 500), random(0, 4), random(0, 4));
shape(shanghailine, 280, 160);

//meteor
float h=random(0, 2000);

if (mousePressed) {
radius=1;
location+=s;
ellipse(h-2*location, location, radius, radius);
stroke(255);
strokeWeight(0.5);
line(h-2*location, location, h-2*location+100, location-50);
}

if(location>300) {
location=-10;
}
}

//black cover
fill(0);
noStroke();
rect(0, 500, width, 200);

//texts
textFont(font1, 48);
if (mouseX<100 || mouseX>=1100) {
fill(#49E5F2);
textFont(font1, 30);
text(“NIGHT”, 570, 580);
textFont(font2, 40);
text(“夜”, 580, 550);
}
else {
fill(255);
textFont(font1, 30);
text(“DAY”, 583, 100);
textFont(font2, 40);
text(“日”, 580, 140);
}
}