Category Archives: Arduino

PhysComp, week 5: Serial Out

I was trying to figure out the math to make part of the graph show up as brown—i.e., earth—and then scatter flowers on top, but something wasn’t working out and I was running late, so I gave up.

Anyway, here are the progress shots:

Setup:
P1000190.JPG

Pot hooked up:
P1000199.JPG

Blinking LED:
P1000204.JPG

I also shot a fascinating movie of the program loading on the Arduino and starting up—you know, flickering yellow light, then blinking LED; hot stuff:

Final code on Arduino:

int potPin = 0;
int potValue = 0;
int ledPin = 2;

void setup()
{
// flash LED three times to announce start of program
pinMode( 2, OUTPUT );
digitalWrite( 2, LOW );
delay( 500 );
digitalWrite( 2, HIGH );
delay( 500 );
digitalWrite( 2, LOW );
delay( 500 );
digitalWrite( 2, HIGH );
delay( 500 );
digitalWrite( 2, LOW );
delay( 500 );
digitalWrite( 2, HIGH );
delay( 500 );
digitalWrite( 2, LOW );
delay( 500 );
digitalWrite( 2, HIGH );

// start serial port at 9600 bps:
Serial.begin( 9600 );
}

void loop()
{
// read analog input, divide by 4 to fit it in the range 0-255:
potValue = analogRead( potPin );
potValue = potValue / 4;
Serial.print( potValue, BYTE );
// pause for 10 milliseconds:
delay( 10 );
}

Final Processing applet

Servo

Two birds, one stone:

Sorry about the wobbles.

This is my video journal of the Servo lab for PhysComp, filmed for CommLab on a Sanyo Xacti 6MP digital movie camera.

I tried to edit this within the Xacti, but I ended up joining the clips together in the wrong order. It was way too much work to separate them again—it’s just a lousy way to edit—so then I dumped the mess into iMovie HD (an older version, recommended by Bre Pettis in his very fine Getting Started in Video series), recut and rearranged it, and added title frames from Photoshop (too bad they look like crap after compression) and CC-licensed music by the excellent Kristin Hersh. This was my first time using iMovie; I found it reasonably intuitive.

So, basically, it’s just the worst video for a Kristin Hersh song ever. Rock on.