September 2007 Archives
Prepare the Breadboard
I prepared the breadboard by putting power to it, and my standard filter capacitors.
Add a Potentiometer and LED
Program the Module
I wrote my own code, based upon Tom Igoe's code written in front of the class.
Other Variable Resistors
I used a light meter almost daily in college for filmmaking, so now I decided that I want to make a darkness meter!
I used a photoresistive sensor and an autoranging algorithm.
The final result is pictured here:
The code is as follows:
Add a Potentiometer and LED
Program the Module
I wrote my own code, based upon Tom Igoe's code written in front of the class.
// Intro PhysComp - Lab 3
// Code by Anderson Miller
// inspired by code by Tom Igoe done in class
int potPin = 0;
int ledPin = 6;
int potValue = 0;
void setup(){
pinMode(potPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop(){
potValue = analogRead(potPin);
analogWrite(ledPin, potValue/4);
delay(10); // per Tom's suggestion
}
I had the following results:
Other Variable Resistors
I used a light meter almost daily in college for filmmaking, so now I decided that I want to make a darkness meter!
I used a photoresistive sensor and an autoranging algorithm.
The final result is pictured here:
The code is as follows:
// Darkness Meter
// C. Anderson Miller
// for Pcomp lab 3
// 9/25/2007
int ledBar[] = {2,3,4,5,6,7,8,9,10,11,12};
int ledNumber = 10;
int lightSensorPin = 0;
int lightSensor;
int minimum = 500;
int maximum = 500;
void setup(){
int i = 0;
for(i=0;i<10;i++){
pinMode(ledBar[i], OUTPUT);
digitalWrite(ledBar[i], LOW);
}
Serial.begin(9600);
}
void loop(){
lightSensor = analogRead(lightSensorPin);
delay(10);
// Serial.println(lightSensor);
if(lightSensor > maximum){
maximum = lightSensor;
}
if(lightSensor < minimum){
minimum = lightSensor;
}
int range = maximum - minimum;
int steps = range/ledNumber;
int steps2light = (lightSensor - minimum)/steps;
Serial.print(steps2light);
steps2light = ledNumber - steps2light; //equation that changes it from a light meter into a darkness meter
int i;
for(i = 0; i < steps2light; i++){
digitalWrite(ledBar[i], HIGH); //light up the affected ones
}
while( i < ledNumber ){
digitalWrite(ledBar[i], LOW); //darken the unnafected ones
i++;
}
}
Resources:
http://itp.nyu.edu/physcomp/Labs/AnalogIn
In the park, where I sometimes take my bagel and coffee in the morning, I saw a man using a contraption, or what might have been a group of contraptions. It was in Bryant Park, in front of the Carousel. He was at a metal table, painted dark green, with 3 legs. He had a boxy black clamshell in front of him, open, but not attached to the table. It was bigger than a regular clamshell, about the size of a big book. There was a plastic pad next to his shell. There was also a coffee cup on his table.
There was a thin black wire coming from the back of the clamshell, to a device on the plastic pad. He'd move this device to and fro along the plastic pad, while he stared into the clamshell.
He also had a black wire going from and earpiece in one of his ears, down to a silver device on his belt, and it may have been related, because he was fiddling with it in between moving the device on the plastic pad. He'd take it off his belt, focus on the silver device, press some buttons, put it back in a holster on his belt, and talk, while he moved his eyes along the inside of the black clamshell.
There were squares on the inside of the black clamshell, and they seemed to respond to his movement of the plastic device. They were small squares filled with numbers.
He looked very anxious, and very different than the other people in the park. Everyone else in the park was enjoying the sunny day, looking around, and he wasn't looking at anything except inside his plastic clamshell. I chose him because his reaction to the world was so different, and that although he was in nature, with a million stimuli around him, he chose to ignore all of them, and look into his clamshell, and talk into his wire.
The goal of this lab is to connect a digital input circuit and a digital output circuit to a microcontroller.
Prepare the breadboard.
I connected a 100uF capacitor at the input of the 7805, and a 10uF capacitor at the output, to regulate voltage spikes and dips.
Add a digital input (a switch).
Add digital output (LEDs).
I chose red and green.
Program the Arduino.
I wrote the following program quickly to try and become more familiar with the Arduino language.
Combination Lock
My combination lock is a simple DIP switch.
The combination has to entered in the order of :
Turn on 1
Turn off 1
Turn on 2
Turn off 2
Turn on 3
Turn off 3
Turn on 4
Turn off 4
The LED blinks for a fraction of a second as each state is changed. 3 rapid blinks (an error message) happens if you get the order wrong.
When you get them all right, the system "unlocks", and a green LED lights up.
my code for my combination lock follows:
Add a digital input (a switch).
Add digital output (LEDs).
I chose red and green.
Program the Arduino.
I wrote the following program quickly to try and become more familiar with the Arduino language.
Combination Lock
My combination lock is a simple DIP switch.
The combination has to entered in the order of :
Turn on 1
Turn off 1
Turn on 2
Turn off 2
Turn on 3
Turn off 3
Turn on 4
Turn off 4
The LED blinks for a fraction of a second as each state is changed. 3 rapid blinks (an error message) happens if you get the order wrong.
When you get them all right, the system "unlocks", and a green LED lights up.
my code for my combination lock follows:
// Code by C. Anderson Miller
// Combination Lock for Lab 2, Intro to Physical Computing
// 9/21/2007
int state[][4] = { //two dimensional array to describe the states involved in the unlock sequence
{LOW, LOW, LOW, LOW}, // state 0
{HIGH, LOW, LOW, LOW}, // state 1
{LOW, LOW, LOW, LOW}, // state 2
{LOW, HIGH, LOW, LOW}, // state 3
{LOW, LOW, LOW, LOW}, // state 4
{LOW, LOW, HIGH, LOW}, // state 5
{LOW, LOW, LOW, LOW}, // state 6
{LOW, LOW, LOW, HIGH}, // state 7
{LOW, LOW, LOW, LOW} // state 8
};
int states = 8;
int inputs = 4;
int debug = 0;
int stateCounter = 0;
int* currentState;
int keyPins[] = {2,3,4,5};
int ledPin = 13;
void setup(){
int i;
for(i=0; i < 4; i++){
pinMode(keyPins[i],INPUT);
}
pinMode(ledPin,OUTPUT);
Serial.begin(9600); //for debugging
}
void loop(){
int i;
for(i = 0; i<4;i++){
currentState[i] = digitalRead(keyPins[i]); //reading in current pin configuration
}
int equal = 1; //assumes equal states until proven otherwise
int advancedState = 1; //likewise with state advances
for(i=0; i < 4; i++){
if( stateCounter < states && currentState[i] != state[stateCounter][i] && equal == 1){
equal = 0;
}
if( stateCounter < states && currentState[i] != state[stateCounter+1][i] && advancedState == 1){
advancedState = 0;
}
}
if( stateCounter < states && advancedState == 1 && equal == 0){
stateCounter++;
blink();
}
if ( equal == 0 && advancedState == 0 && stateCounter < states){
stateCounter = 0;
error();
}
if( stateCounter > states - 1){
goalState();
}
delay(500);
if(debug == 1){ //prints things to serial if the debug variable is equal to 1
Serial.println(stateCounter);
Serial.print("pin 4 ");
Serial.println(digitalRead(keyPins[3]));
Serial.print("advancedState = ");
Serial.print(advancedState);
Serial.print(" equal = ");
Serial.println(equal);
}
}
void goalState(){ //shows unlock
digitalWrite(ledPin,HIGH);
}
void blink(){//subroutine to blink the LED on a correct move
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
}
void error(){ //subroutine to show an error via the ledPin
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(50);
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
delay(50);
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
}
Physical Computing Improv Project:
My action that I've decided on is tapping:

And my object is pudding:
The end goal here, is to have a kinetic motion (pudding jiggling) to happen when a sensor picks up tapping.
As a sensor I picked an accelerometer, and as an actuator, I picked vibration motors.
The circuit I ended up with looks like this:
The pictures of the final product are here:
And with pudding intact:
One vibration motor didn't give enough jiggle, so I used two in parallel:
The sensor was noisy, and my algorithm was (where X = X, Y, and Z axes):
Take Xavg = average sensor reading (20 samples)
Xdiff = abs(Xavg - Xreading)
If Xdiff > Threshold, buzz, else re-run.
The problem with the algorithm, was that as the sensor drifted (as it liked to do), the pudding would start jiggling without reason.
I think if I were to do this project again, a better algorithm would be to use the math.h library (it has square root), take a running average of the inputs, and buzz only for any input that's over one standard deviation above the mean.

And my object is pudding:
The end goal here, is to have a kinetic motion (pudding jiggling) to happen when a sensor picks up tapping.
As a sensor I picked an accelerometer, and as an actuator, I picked vibration motors.
The circuit I ended up with looks like this:
The pictures of the final product are here:
And with pudding intact:
One vibration motor didn't give enough jiggle, so I used two in parallel:
The sensor was noisy, and my algorithm was (where X = X, Y, and Z axes):
Take Xavg = average sensor reading (20 samples)
Xdiff = abs(Xavg - Xreading)
If Xdiff > Threshold, buzz, else re-run.
The problem with the algorithm, was that as the sensor drifted (as it liked to do), the pudding would start jiggling without reason.
I think if I were to do this project again, a better algorithm would be to use the math.h library (it has square root), take a running average of the inputs, and buzz only for any input that's over one standard deviation above the mean.
The PDF can be found here (it's bigger/more detailed).
I made a lobster costume this weekend for a costume party. The materials were egg crate foam, spraypaint, and staples.
Here are the claws:
And here are pictures of me in the costume:
And here are pictures of me in the costume:
Part 1: Measuring Voltage
The first goal of this lab, was to get power to the breadboard, wire it properly for power, and measure the resulting voltage. So here is the wired board:
This board was connected to the 5V and GND pins on the Arduino, in the Red and Blue lanes, respectively.
And the measured voltage that resulted:
My meter is auto-ranging, so I didn't have to set anything special to get it to output at the proper order of magnitude.
I also wired the board so that the opposite side could receive power.
Part 2: The Basic LED Circuit
Then I built my Basic LED circuit. Without the resistor in place, the LED soon gets too bright, then burns out. With a 220 Ohm resistor in place, the LED glows at a reasonable brightness, and can last a long time. I also put a momentary pushbutton switch into the circuit to control it.
The voltage I measured across the LED when the pushbutton switch was engaged was 2.097v. Across the 220Ohm resistor, the voltage was 2.508v.

Seen here in both ON and OFF positions!
I used the following chart to find out which resistor was 220 ohms. (Source 3)
And the wikipedia page on LED's is incredibly helpful as to which end is which: (source 2)
The voltage across each, was 2.403v across red, and 2.475v across yellow (not pictured, done for measurements). Together they added to 4.878, which is really close to 4.91, but as the lab said, there's always some loss.
For curiosity's sake, I used my voltmeter to test the resistance of each diode. Miraculously, each was around 220 Ohms! Each LED has a 220 Ohm resistor in the circuit (in this case another LED) keeping it from burning too brightly.
Part 4: Components in Parallel, Measuring Amperage
Then I connected 3 LEDs in Parallel
The amperage across each in this configuration was 0.67mA.
Each of these were brighter (and hotter!) than they should be, so I thought I'd look up the formula on parallel resistance to see what the correlation here was. (Source 4)
Apparently, in series, resistance stacks like so:
Rtotal = R1 + R2 + R3 + R4(...) .
But in parallel resistance stacks like so:
Rtotal = 1/(1/R1 + 1/R2 + 1/R3 + 1/R4...)
So the total resistance (before/after the LED) for any of those LEDs was 1/(1/220 + 1/220) OR only 110 Ohms. The Total resistance for the circuit by that formula was 73 Ohms.
Part 5: Generating a Variable Voltage with a Potentiometer
The voltage across when the potentiometer was approximately in the center position was 2.803v, across the resistor was 132mV, and across the LED was 1.842v.
Sources:
1. http://itp.nyu.edu/physcomp/Labs/Electronics
2. http://en.wikipedia.org/wiki/LED
3. http://n1ofz.connares.org/resources/resistor_code.gif
4. http://www.outlawnet.com/~oclass/electricity/formulas.htm#parallel
This is a film that I worked on in Fall of my Senior year at JHU (Fall 2005). It's about 40 seconds long, and it's a timelapse of a glass globe as the sun passes it over the course of a day.
Orb - Runtime 0:41 Seconds
You'll probably want to right-click, and "Save Target As" rather than watching it in the browser.
I finally am making use of my candersonmiller.com domain name for something other than hosting my films so that people can view them (although I plan to post those too).









And the following are the painted versions of 2 of my 12 excerpts:

