Tutorial.LEDDriver History

Hide minor edits - Show changes to output

November 11, 2005, at 08:45 AM by 81.236.128.105 -
Changed line 73 from:
delay(100); // waits for a second
to:
delay(100); // waits for a moment
November 10, 2005, at 09:00 PM by 195.178.229.25 -
Added lines 1-77:
!!LED Driver

This example makes use of an LED Driver in order to control an almost endless amount of LEDs with only 4 pins. We use the 4794 from Philips. There is more information about this microchip that you will find in its [[http://webzone.k3.mah.se/projects/arduino-workshop/upload/download.asp?file=51110204007987&enc=False&lang=english | datasheet]].

An LED Driver has a shift register embedded that will take data in serial format and transfer it to parallel. It is possible to daisy chain this chip increasing the total amount of LEDs by 8 each time.

The code example you will see here is taking a value stored in the variable '''dato''' and showing it as a decoded binary number. E.g. if dato is 1, only the first LED will light up; if dato is 255 all the LEDs will light up.

[[http://static.flickr.com/30/61941877_d74eae045b_o.jpg|http://static.flickr.com/30/61941877_d74eae045b.jpg]]

''Example of connection of a 4794''

[=
/* Shift Out Data
* --------------
*
* Shows a byte, stored in "dato" on a set of 8 LEDs
*
* (copyleft) 2005 K3, Malmo University
* @author: David Cuartielles, Marcus Hannerstig
* @hardware: David Cuartielles, Marcos Yarza
* @project: made for SMEE - Experiential Vehicles
*/


int data = 9;
int strob = 8;
int clock = 10;
int oe = 11;
int count = 0;
int dato = 0;

void setup()
{
beginSerial(9600);
pinMode(data, OUTPUT);
pinMode(clock, OUTPUT);
pinMode(strob, OUTPUT);
pinMode(oe, OUTPUT);
}

void PulseClock(void) {
digitalWrite(clock, LOW);
delayMicroseconds(20);
digitalWrite(clock, HIGH);
delayMicroseconds(50);
digitalWrite(clock, LOW);
}

void loop()
{
dato = 5;
for (count = 0; count < 8; count++) {
digitalWrite(data, dato & 01);
//serialWrite((dato & 01) + 48);
dato>>=1;
if (count == 7){
digitalWrite(oe, LOW);
digitalWrite(strob, HIGH);

}
PulseClock();
digitalWrite(oe, HIGH);
}

delayMicroseconds(20);
digitalWrite(strob, LOW);
delay(100);


serialWrite(10);
serialWrite(13);
delay(100); // waits for a second
}


=]

Share