SENDBITS
The complete sketch is available in my Github’s repository.
Data is sent to the display using the ht1632c_send_bits() function:
#define DISPLAY_CS 3 #define DISPLAY_WR 4 #define DISPLAY_DATA 5 |
To understand how it works, you need some skills about bit maths: the function has two parameters: the byte to be sent (bits) and a bitmask (firstbit) the function uses to “extract” each bit from bits.
Let’s see an example: you need to send (in MSB mode) 1011. bits is 00001011 and set firstbit to 00001000. At the first iteration of the while loop you get:
The last instruction of the loop is a right shift of bits moving the 1 one bit to the right. In the next iteration you get:
And so on…
SKETCH
My first example turns on all the leds of the display in succession, starting from the first one (memory address 0) to the last one.
In the main loop, a for loop sends all zeros but for a single position:
for(int i = 0; i < 256; i++) { digitalWrite(DISPLAY_WR, LOW); if(i == j) digitalWrite(DISPLAY_DATA, HIGH); else digitalWrite(DISPLAY_DATA, LOW); digitalWrite(DISPLAY_WR, HIGH); } |
Here’s the sketch running:
How fast can the LEDs be updated? I’d like to write to the matrix so that everything is lit, then send a new image 100 – 300 milliseconds later and repeat this at least 10 times over 3 seconds.
thanks,
Mike
Hi Mike,
referring to the datasheet (http://www.holtek.com/pdf/consumer/ht1632cv120.pdf) you can send data to the Holtek controller up to 1MHz
bye
Hello Luca
Is There any chance to translate your code for other
LED-display from Sure electronics.
I have this LED-Display
http://www.sureelectronics.net/goods.php?id=1136
I try to understand how the HT1632C works but I dont get it 🙁
Hi Ahmet,
unfortunately this is the only display by Sure that I own so I can’t modify/test the code on different models…
Hello
Luca thank you its no problem, i got it
thank you very much! 😀
CIao Luca,
anzitutto complimenti, poi…..
non riesco a capire il codice arduino per accendere un led alla volta. In particolare quando entra nel loop, dove viene incrementato l’indirizzo di memoria dell’ HT1632 ? Io noto che anche ad ogni incremento di j l’indirizzo è sempre lo stesso. Come mai?
Ti ringrazio anticipatamente.
Ciao Giuseppe,
ad ogni “refresh” devi inviare lo stato (ON/OFF) di tutti i led… questo refresh viene gestito dal ciclo sulla variabile i. La variabile j che indica la posizione del led acceso viene invece incrementata nel loop() principale e – se è arrivata a 255, viene riportata a 0. Quindi il loop principale “cicla” la posizione del led acceso, mentre il loop interno invia al display – per ogni ciclo principale – lo stato di tutti i led.
bye
It’s really usefull.Great!Many thanks!
How fast can the LEDs be updated? I’d like to write to the matrix so that everything is lit, then send a new image 100 – 300 milliseconds later and repeat this at least 10 times over 3 seconds.
thanks,
John
Hi John, the controller’s datasheet reports a clock of 256Khz and a frame length of 8*328 ticks… so if your microcontroller is fast enough, you should be able to update the matrix display at the rate you need.