Hide minor edits - Show changes to markup
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 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.
Este ejemplo utiliza un controlador LED que nos permite controlar una cantidad casi ilimitada de LEDs con tan solo 4 pins. Utilizamos el 4794 de Philips. Hay más información acerca de este microchop que podras encontrar en su datasheet. Un controlador LED tiene un shift register incrustado que recibe datos en forma serial y los transfiere en paralelo. Es posible formar una cadena con este chip incrementando la cantidad total de LEDs en 8 por cada unidad.
El codigo de ejemplo que aqui se aprecia toma un valor almacenado en la varibale dato y lo muestra como un numero binario decodificado. Ej: si dato es 1, solo el primer LED se enciende; si dato es 255 todos los LEDs se encenderan.
Example of connection of a 4794
Ejemplo de conexion de un 4794
* Shows a byte, stored in "dato" on a set of 8 LEDs
* Muestra un byte, almacenado en "dato" en un grupo de 8 LEDs.
* @author: David Cuartielles, Marcus Hannerstig
* @autor: David Cuartielles, Marcus Hannerstig
* @project: made for SMEE - Experiential Vehicles
* @proyecto: made for SMEE - Experiential Vehicles
delay(100); // waits for a moment
delay(100); // espera por un momento.
delay(100); // waits for a second
delay(100); // waits for a moment
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 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.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
}