woensdag 19 september 2012

4 leds with 2 74ch595

Problems with 8x8led common anode. photos led matrix: 8x8 led matrix
Scheme:






Arduino code:
// simple 4 led setup.
// 2x 74ch595, 1 for anode, 1 for kathode
// use to test with troubles with 8x8led matrix common anode.
// 4 pins of the 74ch595 are used (A0-A3)

int latchrow = 12; //pin 11 74ch595
int latchcol = 10; //pin 11 74ch595
int clockPin = 9; //pin 12 74ch595
int datarow = 11; //pin 14 74ch595
int datacol = 8;//pin 14 74ch595

byte ledcol = B00001111;
byte ledrow = B00001101;

void setup() {
//set pins to output so you can control the shift register
pinMode(latchrow, OUTPUT);
pinMode(latchcol, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(datarow, OUTPUT);
pinMode(datacol, OUTPUT);
}

void loop() {
digitalWrite(latchrow, LOW);
shiftOut(datarow, clockPin, MSBFIRST, ledrow);
digitalWrite(latchrow, HIGH);

digitalWrite(latchcol, LOW); // shift the bits out:
shiftOut(datacol, clockPin, MSBFIRST, ledcol); // turn on the output so the LEDs can light up: digitalWrite(latchcol, HIGH);
}

Geen opmerkingen: