Recently I have been playing with a light that is made up of a 12x12 grid of RGB LEDs. I made a 5 minute video of most of the sketches I made in the last three days.
LED Color Tile Sketches from Matt Richard on Vimeo.
Wednesday, November 26, 2008
Saturday, November 22, 2008
Robotic arm drawing machine
For our mid-term project in Physical Computing, Jim Lamiell, Kristen Loeb and I created a drawing machine using two servo motors and a little bit of inverse kinematics. We set out to draw a straight line using with a contraption in mind that would mimic a simplified human arm.
The first servo acts like the shoulder and is connected to an arm with another servo at the end that acts like an elbow. The second servo has is connected to another arm with a marker on the end that acts like the hand.
The trick is to tell the servos what angle to go to based on the position of the marker(mouse). This can be done using the law of cosines and inverse kinematics.
We were able to make it draw, but not a straight line. I remade the arms using a CAD program to make it much more precise. I will post another video when it is finished.
PComp Midterm: Drawing Machine from James Lamiell on Vimeo.
The first servo acts like the shoulder and is connected to an arm with another servo at the end that acts like an elbow. The second servo has is connected to another arm with a marker on the end that acts like the hand.
The trick is to tell the servos what angle to go to based on the position of the marker(mouse). This can be done using the law of cosines and inverse kinematics.
We were able to make it draw, but not a straight line. I remade the arms using a CAD program to make it much more precise. I will post another video when it is finished.
PComp Midterm: Drawing Machine from James Lamiell on Vimeo.
Wednesday, November 12, 2008
ICM final
Saturday, November 8, 2008
Coin Flip and Dice Roll generators
Last week for my Crafting with Data class, I had to flip a coin one hundred times and record the results. My teacher told half the class to carry out the experiment and the other half to make up the results.
As I recorded my results I began to get excited about the outcome and cheered for tails(which ended up winning!). I recorded my results on graph paper in a 10x10 grid because I only had small sheets of graph paper. As the results came in, I wondered how the data would look if rendered in black and white squares. I redrew the data on graph paper and I figured it would only take a few moments to recreate the visualization in processing. So I did. I showed it to my Dad and he started talking about dice, so I made one for a six-sided die.
Here are the generators:
Coin Flip
Dice Roll
Sunday, November 2, 2008
28 Minutes Later
Every Tuesday at 4pm, all of the first years have a special class with Red Burns. The first half of the class is used to comment on the special guest the week before. During the second half of class a presenter speaks to us about what they do and then we are able to ask questions.
Last Tuesday, the group presentation consisted of an impromptu creation of video and sound by 9 groups of about 12 ITP students. Each group was given a specific task and the equipment needed to complete it. The groups then split off for 28 minutes to complete their task.
The files were collected, quickly edited and then presented to us.
My group was asked to create audio about a family vacation where a natural disaster occurs. I say "It's okay kids because we are at Old Faithful and it only goes off once an hour."
Warning - contains profanity :)
Last Tuesday, the group presentation consisted of an impromptu creation of video and sound by 9 groups of about 12 ITP students. Each group was given a specific task and the equipment needed to complete it. The groups then split off for 28 minutes to complete their task.
The files were collected, quickly edited and then presented to us.
My group was asked to create audio about a family vacation where a natural disaster occurs. I say "It's okay kids because we are at Old Faithful and it only goes off once an hour."
Warning - contains profanity :)
Ideas about Consciousness
Ze Frank, a popular internet icon, created a video about the way our conscious mind works. He sites elements from a New York Times article entitled, "Free Will: Now You Have It, Now You Don’t."
The article and Ze Frank both touch on a 1970's experiment by Benjamin Libet where he "...wired up the brains of volunteers to an electroencephalogram and told the volunteers to make random motions, like pressing a button or flicking a finger, while he noted the time on a clock." Libet found out that actions in the body occurred before areas in the conscious mind were aware, leading him to question the ideas of free will.
The article and Ze Frank both touch on a 1970's experiment by Benjamin Libet where he "...wired up the brains of volunteers to an electroencephalogram and told the volunteers to make random motions, like pressing a button or flicking a finger, while he noted the time on a clock." Libet found out that actions in the body occurred before areas in the conscious mind were aware, leading him to question the ideas of free will.
Tuesday, October 21, 2008
Inverse Kinematics and Processing
Basic inverse kinematics code rewritten for processing from Keith Peters of bit-101. The idea is to replicate the motion of your shoulder, upper arm, elbow, lower arm, and hand in two dimensions. The angular value of the "shoulder" and "elbow" will be written to corresponding servo motors that are being controlled by Arduino.
Here is the code:
int sx,sy,ex,ey,hx,hy;
int armLength,ua,la;
float uad, lad;
void setup(){
size(500,500);
background(255, 224, 150);
sx = width/2;
sy = height/2;
armLength = int(width/5);
}
void draw(){
fill(255);
rect(0,0,width,height);
upperArm();
}
void upperArm(){
int dx = mouseX - sx;
int dy = mouseY - sy;
float distance = sqrt(dx*dx+dy*dy);
int a = armLength;
int b = armLength;
float c = min(distance, a + b);
float B = acos((b*b-a*a-c*c)/(-2*a*c));
float C = acos((c*c-a*a-b*b)/(-2*a*b));
float D = atan2(dy,dx);
float E = D + B + PI + C;
ex = int((cos(E) * a)) + sx;
ey = int((sin(E) * a)) + sy;
print("UpperArm Angle= "+degrees(E)+" ");
hx = int((cos(D+B) * b)) + ex;
hy = int((sin(D+B) * b)) + ey;
println("LowerArm Angle= "+degrees((D+B)));
stroke(255,0,0,100);
fill(240,0,0,200);
ellipse(sx,sy,10,10);
ellipse(ex,ey,8,8);
ellipse(hx,hy,6,6);
stroke(0);
line(sx,sy,ex,ey);
line(ex,ey,hx,hy);
}
Awesome Data Visualization Site
My friend Loren Klein sent me a link to a site called Very Small Array. The specific page shows the map of the five boroughs. Instead of the borough names, the names of States with the closest equivalent in population are used. I really recommend checking out the rest of the site.
Money Map
Multi-Value Serial Communication
I want to thank Meredith for writing this post. I merely changed my name to her's.
I worked with Meredith Hasson on the serial communication lab for this week. We followed the lab instructions and did the first basic serial circuit using a flex sensor, a photo cell and a switch. We were able to get it working and thus, began to play with moving the ball around the screen.
We then changed both the Arduino and Processing code up a bit and went for snow. We made the background color change based on how much light the photocell was receiving. When it was getting lots of light, it would be a light background and when it was not receiving any light, it was a black background. The white balls were moving around based off of random numbers, but we utilized the flex sensor to decide how many balls would be present. When bent one way there were lots of balls and when bent the other there were fewer balls.
Here is our code:
Arduino:
int analogOne = 0; // analog input
int analogTwo = 1; // analog input
int digitalOne = 2; // digital input
int sensorValue = 0; // reading from the sensor
void setup() {
// configure the serial connection:
Serial.begin(9600);
// configure the digital input:
pinMode(digitalOne, INPUT);
}
void loop() {
// read the sensor:
sensorValue = analogRead(analogOne);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(”,”);
// read the sensor:
sensorValue = analogRead(analogTwo);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(”,”);
// read the sensor:
sensorValue = digitalRead(digitalOne);
// print the last sensor value with a println() so that
// each set of four readings prints on a line by itself:
Serial.println(sensorValue, DEC);
}
Processing:
import processing.serial.*; // import the Processing serial library
Serial myPort; // The serial port
float bgcolor; // Background color
float fgcolor; // Fill color
float xpos, ypos; // Starting position of the ball
void setup() {
size(640,480);
myPort = new Serial(this, Serial.list()[2], 9600);
// read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(’\n’);
}
void draw() {
//background(xpos);
fill(xpos, 50);
rect(0, 0, width, height);
fill(fgcolor);
// Draw the shape
for(int i = 0; i <= ypos; i++){
// ellipse(i*10, height/2, 10, 10);
ellipse(random(width), random(height), 10, 10);
}
}
// serialEvent method is run automatically by the Processing applet
// whenever the buffer reaches the byte value set in the bufferUntil()
// method in the setup():
void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil('\n');
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ','));
// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
}
// add a linefeed after all the sensor values are printed:
println();
if (sensors.length > 1) {
xpos = map(sensors[0], 190,900,1,255);
ypos = map(sensors[1], 220,540,1,200);
fgcolor = sensors[2] * 255;
}
}
}
I worked with Meredith Hasson on the serial communication lab for this week. We followed the lab instructions and did the first basic serial circuit using a flex sensor, a photo cell and a switch. We were able to get it working and thus, began to play with moving the ball around the screen.
We then changed both the Arduino and Processing code up a bit and went for snow. We made the background color change based on how much light the photocell was receiving. When it was getting lots of light, it would be a light background and when it was not receiving any light, it was a black background. The white balls were moving around based off of random numbers, but we utilized the flex sensor to decide how many balls would be present. When bent one way there were lots of balls and when bent the other there were fewer balls.
Here is our code:
Arduino:
int analogOne = 0; // analog input
int analogTwo = 1; // analog input
int digitalOne = 2; // digital input
int sensorValue = 0; // reading from the sensor
void setup() {
// configure the serial connection:
Serial.begin(9600);
// configure the digital input:
pinMode(digitalOne, INPUT);
}
void loop() {
// read the sensor:
sensorValue = analogRead(analogOne);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(”,”);
// read the sensor:
sensorValue = analogRead(analogTwo);
// print the results:
Serial.print(sensorValue, DEC);
Serial.print(”,”);
// read the sensor:
sensorValue = digitalRead(digitalOne);
// print the last sensor value with a println() so that
// each set of four readings prints on a line by itself:
Serial.println(sensorValue, DEC);
}
Processing:
import processing.serial.*; // import the Processing serial library
Serial myPort; // The serial port
float bgcolor; // Background color
float fgcolor; // Fill color
float xpos, ypos; // Starting position of the ball
void setup() {
size(640,480);
myPort = new Serial(this, Serial.list()[2], 9600);
// read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(’\n’);
}
void draw() {
//background(xpos);
fill(xpos, 50);
rect(0, 0, width, height);
fill(fgcolor);
// Draw the shape
for(int i = 0; i <= ypos; i++){
// ellipse(i*10, height/2, 10, 10);
ellipse(random(width), random(height), 10, 10);
}
}
// serialEvent method is run automatically by the Processing applet
// whenever the buffer reaches the byte value set in the bufferUntil()
// method in the setup():
void serialEvent(Serial myPort) {
// read the serial buffer:
String myString = myPort.readStringUntil('\n');
// if you got any bytes other than the linefeed:
if (myString != null) {
myString = trim(myString);
// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ','));
// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
}
// add a linefeed after all the sensor values are printed:
println();
if (sensors.length > 1) {
xpos = map(sensors[0], 190,900,1,255);
ypos = map(sensors[1], 220,540,1,200);
fgcolor = sensors[2] * 255;
}
}
}
Tags:
arduino,
physical computing,
processing,
serial input
Subscribe to:
Posts (Atom)