Buon Giorno a tutti,
ho acquistato questo display (http://www.canton-electronics.com/arduino-kit-5-digit-7-seg-serial-double-lcd-module-uno-mega2560-example-sketch-p-714.html) perchè avevo la necessità, leggendo una tensione da 0 a 5V, di visualizzare su un display la velocita di avanzamento di un asse comandato da azionamento, e nell'altro i giri di un motore comandato da inverter.
Per il cablaggi, non ci sono problemi, il discorso si complica, perchè non riesco a capire come programmare questo codice.
Qualcuno sa darmi delle dritte o consigliarmi cosa leggere per cercare di capire come fare?
Premessa, sono ASSOLUTAMENTE NEOFITA !!!
questo lo SKETCH di esempio:
//Author: cantone-electonics
//More information welcome to : http://www.canton-electronics.com
//Arduino 1.0.4
//Arduino uno R3
//2x5 DIGIT 7SEG LCD
/*---Segment Display Screen----
--5--
1---6
--2--
3---7
--4--
8 decimal point
----------------------*/
#define sbi(x, y) (x |= (1 << y)) /*set Register x of y*/
#define cbi(x, y) (x &= ~(1 <<y )) /*Clear Register x of y*/
#define uchar unsigned char
#define uint unsigned int
//Defined HT1621's command
#define ComMode 0x52 //4COM,1/3bias 1000 010 1001 0
#define RCosc 0x30 //on-chip RC oscillator(Power-on default)1000 0011 0000
#define LCD_on 0x06 //Turn on LCD
#define LCD_off 0x04 //Turn off LCD
#define Sys_en 0x02 //Turn on system oscillator 1000 0000 0010
#define CTRl_cmd 0x80 //Write control cmd
#define Data_cmd 0xa0 //Write data cmd
// //Define port HT1621 data port
#define CS 2 //Pin 2 as chip selection output
#define WR 3 //Pin 3 as read clock output
#define DATA 4 //Pin 4 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)
char dispnum[6]={0x00,0x00,0x00,0x00,0x00,0x00};
/*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 num[]={0x7D,0x60,0x3E,0x7A,0x63,0x5B,0x5F,0x70,0x7F,0x7B,0x77,0x4F,0x1D,0x0E,0x6E,0x1F,0x17,0x67,0x47,0x0D,0x46,0x75,0x37,0x06,0x0F,0x6D,0x02,0x00,};
/**-------------------------------------------------------------------------
Name: SendBit_1621(send data)
---------------------------------------------------------------------------*/
void SendBit_1621(uchar sdata,uchar cnt) //High bit first
{
uchar i;
for(i=0;i<cnt;i++)
{
WR0;
delayMicroseconds(20);
if(sdata&0x80) DATA1;
else DATA0;
delayMicroseconds(20);
WR1;
delayMicroseconds(20);
sdata<<=1;
}
//delay_nus(20);
}
/**-------------------------------------------------------------------------
Name: SendCmd(send cmd)
//Write MODE“100” AND 9 bits command
---------------------------------------------------------------------------*/
void SendCmd_1621(uchar command)
{
CS0;
SendBit_1621(0x80,4);
SendBit_1621(command,8);
CS1;
}
/**-------------------------------------------------------------------------
Name: Write_1621send data and cmd)
---------------------------------------------------------------------------*/
void Write_1621(uchar addr,uchar sdata)
{
addr<<=2;
CS0;
SendBit_1621(0xa0,3); //Write MODE“101”
SendBit_1621(addr,6); //Write addr high 6 bits
SendBit_1621(sdata,8); //Write data 8 bits
CS1;
}
/**-------------------------------------------------------------------------
Name: all_off(Clear Display)
---------------------------------------------------------------------------*/
void HT1621_all_off(uchar num)
{ uchar i;
uchar addr=0;
for(i=0;i<num;i++)
{
Write_1621(addr,0x00);
addr+=2;
}
}
/****************************************************************************
Name: all_on(All lit)
****************************************************************************/
void HT1621_all_on(uchar num)
{ uchar i,j;
uchar addr=0;
for(i=0;i<num;i++)
{ Write_1621(addr,0xff);
addr+=2;
}
} /****************************************************************************
Name: all_on_num(All lit,Display the same number)
****************************************************************************/
void HT1621_all_on_num(uchar num,uchar xx)
{ uchar i,j;
uchar addr=0;
for(i=0;i<num;i++)
{ Write_1621(addr,xx);
addr+=2;
}
}
/****************************************************************************
Name: Init_1621(initialize 1621)
*****************************************************************************/
void Init_1621(void)
{
SendCmd_1621(Sys_en);
SendCmd_1621(RCosc);
SendCmd_1621(ComMode);
SendCmd_1621(LCD_on);
}
/****************************************************************************
Name: LCDoff(off 1621)
*****************************************************************************/
void LCDoff(void)
{
SendCmd_1621(LCD_off);
}
