learning the ropes

things I made at ITP and after: sketches, prototypes, and other documentation

Monday, September 25, 2006

Lab 2 – Analog Inputs (part 2)

When considering what to do for the creative part of my Physical Computing lab, I initially thought of some sort of mood-proclaiming piece of clothing.

Instead of using a flex or pressure sensor to light up the LEDs on a “luv-o-meter,” I wanted to prototype a display for a t-shirt that could display a short and partially encrypted message about the wearer’s stress level. I remember seeing a persistence of vision project on one of my first trips to ITP (perhaps it was the winter show?) and thought I might be able to make a single column of LEDs light up and scroll the message past.

Using only a slightly modified version of the circuit from my game of catch, I set about drafting some code to drive a vertical array of 5 LEDs.


(written during experimentation)
- First attempt unsuccessful… I tried moving my head back and forth to see the image, but didn’t get to a point where I could see the image persisting. In the interest of time, though, I’m going to try a couple more speeds before I set about rewiring

- I added potentiometers to the circuit in order to vary the delay between the columns of the character as well as between each letter. When I move the board back and forth I can make out the characters, but it seems like they might be going backwards.

- Seems like the rocking back and forth I’m doing may be causing the character to be rendered backwards. On the bicycle example, the direction is constant. I wonder how the clock I’ve seen that uses this trick works… it swings back and forth… perhaps it has to write the characters in reverse order…

I could eventually try mounting this contraption on a motor

/* ----------------------------------------
Persistence
----------------------------------------
Michael Chladil

Physical Computing
2006-09-23

written for Arduino v1.18

----------------------------------------
*/

#include 

#define DEBUG_LVL 1

// Going to try first with 5-line characters
#define CharacterPin1 3
#define CharacterPin2 4
#define CharacterPin3 5
#define CharacterPin4 6
#define CharacterPin5 7
#define CHAR_WIDTH    5
#define CHAR_HEIGHT   5

byte Letter_M[CHAR_WIDTH][CHAR_HEIGHT] = { {1, 0, 0, 0, 1},
{1, 0, 0, 0, 1},
{1, 1, 0, 1, 1},
{1, 0, 1, 0, 1},
{1, 0, 0, 0, 1} };

byte Letter_C[CHAR_WIDTH][CHAR_HEIGHT] = { {0, 1, 1, 1, 1},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{0, 1, 1, 1, 1} };

#define CharacterPin6 8
#define CharacterPin7 9
#define Switch1  10
#define Switch2  11

int delayTime      = 0;
int charRow        = 0;
int interCharDelay = 0;

void setup ()
{
pinMode (CharacterPin1, OUTPUT);
pinMode (CharacterPin2, OUTPUT);
pinMode (CharacterPin3, OUTPUT);
pinMode (CharacterPin4, OUTPUT);
pinMode (CharacterPin5, OUTPUT);

pinMode (Switch1, INPUT);
pinMode (Switch2, INPUT);

if (DEBUG_LVL > 0)
{
Serial.begin (9600);
}
}

void writeChar (char charToWrite)
{
byte Letter[5][5];
int charCol = 0;
int charRow = 0;
int i;

// Needed a way to copy the constants I defined above without going
// pixel by pixel.  memcpy seems to do the trick.  I initially wanted
// to copy the entire 2-D array at once, but it didn't seem to work
// and I wanted to move on to verifying other things
switch (charToWrite)
{
case 'M' :
{
for (int i = 0; i < CHAR_HEIGHT; i++)
memcpy (Letter[i], Letter_M[i], CHAR_WIDTH);

break;
}
case 'C' :
{
for (int i = 0; i < CHAR_HEIGHT; i++)
memcpy (Letter[i], Letter_C[i], CHAR_WIDTH);

break;
}
}

for (charCol = 0; charCol < CHAR_WIDTH; charCol++)
{
for (charRow = 0; charRow < CHAR_HEIGHT; charRow++)
{
digitalWrite(CharacterPin1 + charRow, Letter[charRow][charCol]);
}

delay (delayTime);

for (charRow = 0; charRow < CHAR_HEIGHT; charRow++)
{
digitalWrite(CharacterPin1 + charRow, LOW);
}
delay (10);
}
}

void loop()
{
delayTime      = analogRead(5);
interCharDelay = analogRead(4);

writeChar('M');
delay(interCharDelay);
writeChar('C');
delay(interCharDelay);
}
posted by Michael at 11:12 pm  

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress