Transflective Segment HT1621B Alphanumeric LCD Display Module
This item is a 3 digit 7-segment LCD display module. It features large White on Black LCD digits displayed against resulting in a clear and easy to read display. Communication to the module is via a 5V serial interface requiring only 3 digital pins (CS, WR, Data). Additionally, this 3 digit display module also features many symbols icon like battery ,charge icon temperature setting error and other useful icons to meet many projects and ideas requirements .
we developed Arduino code to drive all segment and show counting up number please check it and customize according to your specific need
“`cpp
#define CS 5 //Pin 13 as chip selection output
#define WR 13 //Pin 12 as read clock output
#define DATA 2 //Pin 7 as Serial data output
#define CS1 digitalWrite(CS, HIGH)
#define CS0 digitalWrite(CS, LOW)
#define WR1 digitalWrite(WR, HIGH)
#define WR0 digitalWrite(WR, LOW)
#define DATA1 digitalWrite(DATA, HIGH)
#define DATA0 digitalWrite(DATA, LOW)
#define sbi(x, y) (x |= (1 << y))
#define cbi(x, y) (x &= ~(1 << y ))
#define uchar unsigned char
#define uint unsigned int
#define ComMode 0x52 //4COM,1/3bias 1000 010 1001 0
#define RCosc 0x30 //1000 0011 0000
#define LCD_on 0x06 //1000 0000 0 11 0
#define LCD_off 0x04
#define Sys_en 0x02 //1000 0000 0010
#define CTRl_cmd 0x80
#define Data_cmd 0xa0
#define SCENTG 0
#define SFEHR 1
#define SSET 2
#define SIN 3
#define SLVL5 4
#define SSETTING 5
#define SERROR 6
#define SBAT 7
/*0,1,2,3,4,5,6,7,8,9,A,b,C,c,d,E,F,H,h,L,n,N,o,P,r,t,U,-, ,*/
const char sym[]={1,2,4,8,16,32,64,128};
const char num[]={95,80,61,121,114,107,111,81,127,123,0×77,0x4F,0x1D,0x0E,0x6E,0x1F,0x17,0x67,0x47,0x0D,0x46,0x75,0x37,0x06,0x0F,0x6D,0x02,0x00};
//0 1 2 3 4 5 6 7 8 9
char dispnum[3]={0x00,0x00,0x00};
int i = 0;
word count=0;
byte symbol1=0;
byte symbol2=0;
byte symbol3=0;
void SendBit_1621(uchar sdata,uchar cnt)
{
//data cnt HT1621
uchar i;
for(i=0;i<cnt;i++)
{
WR0;
if(sdata&0x80) DATA1;
else DATA0;
WR1;
sdata<<=1;
}
}
void SendCmd_1621(uchar command)
{
CS0;
SendBit_1621(0x80,4);
SendBit_1621(command,8);
CS1;
}
void Write_1621(uchar addr,uchar sdata)
{
addr<<=2;
CS0;
SendBit_1621(0xa0,3);
SendBit_1621(addr,6);
SendBit_1621(sdata,8);
CS1;
}
void HT1621_all_off(uchar num)
{
uchar i;
uchar addr=0;
for(i=0;i<num;i++)
{
Write_1621(addr,0x00);
addr+=2;
}
}
void HT1621_all_on(uchar num)
{
uchar i;
uchar addr=0;
for(i=0;i<num;i++)
{
Write_1621(addr,0xff);
addr+=2;
}
}
void Init_1621(void)
{
SendCmd_1621(Sys_en);
SendCmd_1621(RCosc);
SendCmd_1621(ComMode);
SendCmd_1621(LCD_on);
}
void displaydata(int p)
{
uchar i=0;
switch(p)
{
case 1:
sbi(dispnum[0],7);
break;
case 2:
sbi(dispnum[1],7);
break;
case 3:
sbi(dispnum[2],7);
break;
default:break;
}
for(i=0;i<=5;i++)
{
Write_1621(i*2,dispnum[i]);
}
}
void showsym1(byte symb1, bool on)
{
if(on) Write_1621(2,sbi(symbol1,symb1));
else Write_1621(2,cbi(symbol1,symb1));
}
void showsym2(byte symb2, bool on)
{
if(on) Write_1621(10,sbi(symbol2,symb2));
else Write_1621(10,cbi(symbol2,symb2));
}
void showsym3(byte symb3, bool on)
{
if(on) Write_1621(0,sbi(symbol3,symb3));
else Write_1621(0,cbi(symbol3,symb3));
}
void setup() {
pinMode(A5,INPUT_PULLUP);
Serial.begin(9600);
pinMode(CS, OUTPUT); //
pinMode(WR, OUTPUT); //
pinMode(DATA, OUTPUT); //
CS1;
DATA1;
WR1;
delay(50);
Init_1621();
HT1621_all_on(16); //1621
delay(5000);
HT1621_all_off(16); //1621
delay(100);
}
void loop() {
if(digitalRead(A5)==0) showsym1(SERROR,1);
else showsym1(SERROR,0);
if(count<999) {count++;
dispnum[2]=(count/100)%10;
dispnum[1]=(count/10)%10;
dispnum[0]=count%10;
Write_1621(8,num[dispnum[2]]);
Write_1621(6,num[dispnum[1]]+128);
Write_1621(4,num[dispnum[0]]);
showsym1(SBAT,1);
delay(300);
showsym1(SBAT,0);
delay(300);
}
else{count=0;
dispnum[2]=(count/100)%10;
dispnum[1]=(count/10)%10;
dispnum[0]=count%10;
Write_1621(8,num[dispnum[2]]);
Write_1621(6,num[dispnum[1]]+128);
Write_1621(4,num[dispnum[0]]);
delay(500);
}
/*
while (i < 8)
{
Write_1621(0,sym[i]);
//Write_1621(2,num[i]);
//Write_1621(4,num[i]);
//Write_1621(6,num[i]);
//Write_1621(8,num[i]);
//Write_1621(10,num[i]);
delay(1000);
Serial.println(i);
i=i+1;
}
i = 0;
*/
}
“`
| Weight | 0.024 kg |
|---|
You must be logged in to post a review.
Reviews
There are no reviews yet.