Hey!
So I have been playing around a bit with a 4x4 led matrix and 74HC595 following this one:
It seems as there are a performance issue as the LEDs are a bit dim compared to what they should be. Guessing some timing/slowness with the code using shiftout.
The code is working otherwise:
//LED TEST 2 w/ 74HC595
//by Amanda Ghassaei 2012
//https://www.instructables.com/id/Multiplexing-with-Arduino-and-the-74HC595/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
//this code sends data to the 74HC595 without "shiftOut"
//pin connections- the #define tag will replace all instances of "latchPin" in your code with A1 (and so on)
#define latchPin A1
#define clockPin A0
#define dataPin A2
//looping variables
byte i;
byte j;
//storage variable
byte dataToSend;
//storage for led states, 4 bytes
byte ledData[] = {15, 15, 15, 15};
void setup() {
//set pins as output
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
for (i=0;i<4;i++){
//send data from ledData to each row, one at a time
byte dataToSend = (1 << (i+4)) | (15 & ~ledData[i]);
// setlatch pin low so the LEDs don't change while sending in bits
digitalWrite(latchPin, LOW);
// // shift out the bits of dataToSend to the 74HC595
// shiftOut(dataPin, clockPin, LSBFIRST, dataToSend);
// the code below is the equivalent of the two lines above
for (j=0;j<8;j++){
digitalWrite(clockPin,LOW);
digitalWrite(dataPin,((dataToSend>>j)&1));
digitalWrite(clockPin,HIGH);
}
//set latch pin high- this sends data to outputs so the LEDs will light up
digitalWrite(latchPin, HIGH);
}
}
I have tried to search around for similar topics, some is suggesting to use SPI and some says that SPI is not needed.
Is there any sketches available for SPI in this case? Or is there a way to fix the above code?
Multiplexed LEDs will always be dimmer than the same LED with the same value resistor that is not being multiplexed. Looks like you are driving a 4x4 grid, each LED will have roughly the same brightness as a single LED being driven with PWM at 25% ON time.
Schematics would be helpful. As already told, when multiplexing, the current needs to be higher to get higher illumination.
I ounce boosted a simple 20-30 mA LED to 7 Amps. The voltage across the LED was some 7 volt. The pulse was 1 microsecond long and the duty cycle 1 ppm, 1 pulse per 1 000 000 microseconds..... It was shining "as normal"....
Whoops ... no bypass capacitor in the instructable. Did you add one? (or two ... 1μF paralleled with 0.1μF as close as possible to the 74HC595's power pins) as suggested here.
That does seem rather excessive.
Often the LED specs will list the forward current, for use when the LED is on continuously, and a much larger peak forward current, with some stipulation of duty cycle or pulse width, for then the LED will be multiplexed.
I You want to raise the current by lowering the resistor that I would go for a bypass cap of some 10..... 47 uF. Watch out for the max current for the 74HC595.
You extract the schematics, not helpers, and post it here. Most helpers don't like to fill their equipment with downloads. Many helpers use phones, tablets that has less memory and need frequent cleaning.
"Most helpers don´t like to fill their equipment with downloads"
Not sure I'm following here.
It is a link to a regular website. It does not warrant anything other then browsing to that site.
Is it browser cache you are referring to? I would think that this is not a issue with 2022 devices.