tonymcgregor
Published © GPL3+

3.5 Digit LCD Library for HT1621 Display

These 3.5 digit displays are available very cheaply and include a backlight. This library makes them easy to use with an audino.

IntermediateProtip2,527
3.5 Digit LCD Library for HT1621 Display

Things used in this project

Hardware components

lcd 3.5 digit HT1621
×1

Story

Read more

Code

Ht1621 Library

C/C++
Install into the Arduino IDE using the sketch menu or unpack and put in the directory with your sketch.
No preview (download only).

Example Code

Arduino
#include "Ht1621.h"

const byte CS_PIN =   2;  //chip selection output
const byte WR_PIN =   3;  //read clock output
const byte DATA_PIN = 4;  //Serial data output
const byte BKLT_PIN = 5;  //Backlight

const byte BKLT_TIMEOUT = 5;  //Backlight timeout


//Declare an Ht1621 object. If you have more than one display, you can
//declare several (untested).
Ht1621 ht(CS_PIN, WR_PIN, DATA_PIN, BKLT_PIN, BKLT_TIMEOUT);


//---------------------------------------------------------------------------
void setup(){
  ht.init();
}


//===========================================================================
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void loop() {
  static int n = 0;
  static unsigned long waitTill = 0;

  ht.poll();
  if ( waitTill && millis() < waitTill ){ return; }
  if ( n > 1999 ){ n = -1; }
  ht.writeNumber(++n);
  delay(200);

  if ( n % 100 == 0 ){ 
      waitTill = millis() + BKLT_TIMEOUT * 1000 + 2000;
  }
}



// Emacs control
// Local Variables:
// eval: (c++-mode)
// End:

Credits

tonymcgregor
0 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.