Close

Example sketch - with lots and lots of comments

A project log for Arduino, HT16C32, and the Library

While a simple example of putting a 8x32 matrix on an Arduino, a more in-depth look at a library for the noobs and non-career- programmers.

peterPeter 09/05/2019 at 01:050 Comments

Here is my commented code for an example of using an Arduino Nano with a HT1632C 8x32 panel. 

// Libraries needed for the demo
#include <HT1632.h>
#include <font_5x4.h>

// Set the variables
// integers
int i = 0;
int wd;

// a string of characters to display
char disp [] = "Welcome to TVLand!";

void setup () {
  // Which pins is the display using. 
  // The pin order is (CS1, pinWR, pinDATA)
  HT1632.begin(9, 10, 11);

  // Setting up the font
  wd = HT1632.getTextWidth(disp, FONT_5X4_END, FONT_5X4_HEIGHT);
}

void loop () {
  // Original code - drawTarget not a keyword
  // HT1632.drawTarget(BUFFER_BOARD(1));
  // Below, renderTarget, reflects the updated library - v2.0,
  // which screen to send the data to. There can be up to 4 panels.
  HT1632.renderTarget(1);
  
  // Clear the RAM buffer for the display
  HT1632.clear();
  
  // OUT_SIZE, FONT_5X4, FONT_5X4_END, FONT_5X4_HEIGHT
  // All of the above variables come from the font.h file
  // OUT_SIZE is the width of the display
  HT1632.drawText(disp, OUT_SIZE - i, 2, FONT_5X4, FONT_5X4_END, FONT_5X4_HEIGHT);
  
  // Display the contents of RAM to the screen
  HT1632.render();

  // Scrolling the text from right to left
  i = (i+1)%(wd + OUT_SIZE);

  // a quick pause before cycling through
  delay(100);
}

Discussions