February 05, 2010

Coded up an arduino led array.
Next step, scrolling text and the world’s smallest (actually probably not) LED sign.
The code, in case you care, or if you arrive here via search.
/* 5 by 7 LED array The circuit: * LED array connected to pins 1-14 (don’t use 0) led array is LTP1557AKR Using freeduino Created 5 Feb 2010 By Douglas Tarlow */const int pin14 = 12; //pin 12 is unused b/c of overlap (see datasheet) but it would be pin 14, or an analog // so this just helps us keep it straight//sets up the board, makes sure all pins are output, and turns off all active LEDsvoid setup()   {                 // initialize all digital pins to output pinMode(1, OUTPUT); pinMode(2, OUTPUT);  pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT);  pinMode(11, OUTPUT);  pinMode(pin14, OUTPUT); pinMode(13, OUTPUT); all_Off();}//this function takes row and col arguments, and turns the LED at those coordinates onvoid led_On(int row, int col){ digitalWrite(row, HIGH); digitalWrite(col, LOW);}void all_Off() { //this turns all the leds off, high low values determined from datasheet //all anodes turned low and all cathodes to HIGH digitalWrite(1, LOW); digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, LOW); digitalWrite(6, HIGH); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); digitalWrite(10, HIGH); digitalWrite(11, HIGH); digitalWrite(pin14, LOW); digitalWrite(13, HIGH);}//this function converts led cordinates to pin cordinates, again, datasheet used as sourceint led2pin(int ledPosition, int row_Or_col ){ //row is 0, col is 1   if (row_Or_col == 0){ switch (ledPosition){ case 1: return 9; case 2: return pin14; case 3: return 8; case 4: return 5; case 5: return 1; case 6: return 7; case 7: return 2; } }else if (row_Or_col == 1){ switch (ledPosition){ case 1: return 13; case 2: return 3; case 3: return 4; case 4: return 10; case 5: return 6;     } }}//iterates thru all the leds to run a basic board checkvoid testBoard(){ int delayTime = 1; // amount of time to delay b/w led changes, can also be used to create illusion of all leds on w/out current problems for (int row = 1; row < 8; row++){ for (int col = 1; col < 6; col++){ int col_pin = led2pin(col, 1); int row_pin = led2pin(row, 0); led_On(row_pin, col_pin); delay( delayTime); all_Off(); } }}void loop(){ testBoard(); //this is where the cool stuff happens later =p }

Coded up an arduino led array.

Next step, scrolling text and the world’s smallest (actually probably not) LED sign.

The code, in case you care, or if you arrive here via search.

/*
5 by 7 LED array
The circuit:
* LED array connected to pins 1-14 (don’t use 0)
led array is LTP1557AKR

Using freeduino
Created 5 Feb 2010
By Douglas Tarlow

*/

const int pin14 = 12; //pin 12 is unused b/c of overlap (see datasheet) but it would be pin 14, or an analog
// so this just helps us keep it straight


//sets up the board, makes sure all pins are output, and turns off all active LEDs
void setup()   {               
// initialize all digital pins to output
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(pin14, OUTPUT);
pinMode(13, OUTPUT);
all_Off();
}

//this function takes row and col arguments, and turns the LED at those coordinates on
void led_On(int row, int col){
digitalWrite(row, HIGH);
digitalWrite(col, LOW);
}

void all_Off() { //this turns all the leds off, high low values determined from datasheet
//all anodes turned low and all cathodes to HIGH
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(pin14, LOW);
digitalWrite(13, HIGH);
}

//this function converts led cordinates to pin cordinates, again, datasheet used as source
int led2pin(int ledPosition, int row_Or_col ){ //row is 0, col is 1 

if (row_Or_col == 0){
switch (ledPosition){
case 1:
return 9;
case 2:
return pin14;
case 3:
return 8;
case 4:
return 5;
case 5:
return 1;
case 6:
return 7;
case 7:
return 2;
}
}else if (row_Or_col == 1){

switch (ledPosition){
case 1:
return 13;
case 2:
return 3;
case 3:
return 4;
case 4:
return 10;
case 5:
return 6;   
}
}
}
//iterates thru all the leds to run a basic board check
void testBoard(){
int delayTime = 1; // amount of time to delay b/w led changes, can also be used to create illusion of all leds on w/out current problems
for (int row = 1; row < 8; row++){
for (int col = 1; col < 6; col++){
int col_pin = led2pin(col, 1);
int row_pin = led2pin(row, 0);
led_On(row_pin, col_pin);
delay( delayTime);
all_Off();
}
}
}

void loop(){
testBoard();
//this is where the cool stuff happens later =p
}

blog comments powered by Disqus
Comments

About

Hello. My name is Douglas Tarlow. I am a 22 year old Product Design Major at Stanford University. I'm interested in innovation, creative processes, startups, and silicon valley. This is my journal of my web usage, its a way for me to justify to myself why I spend so much time on the internet. Please send any complaints to my Mother or the doctor
UPDATE: I would love if you emailed me, I'm currently working on new media, design, and "viral" marketing. Google Voice: call me.

Options

Find me

Search

Following

  • marc
  • quotesixty
  • omgpop
  • marco
  • hrrrthrrr
  • mattmcinerney
  • 60gritbeard
  • taf
  • designerdaily
  • stefyania
  • spaceships
  • aboveandbeyond
  • synmirror
  • karenh
  • staff
  • chanett
  • lamb
  • sid05
  • suspectdevice
  • benkraal
  • bauldoff
  • randomonium
  • tinyblip
  • aliens-exist
  • 147xxxx
  • gadgetgirl81
  • clusterfxck
  • dihard
  • morepete
  • whiteonwhite
  • guster
  • didyouevernotice
  • caffeinisms
  • carlygeehr
  • riccardoluna
  • millionmilepledge
  • nickyszmala
  • lightsculpture
  • benglish
  • sepatown
  • portfolios
  • planapple