Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <at89c5131.h>
#include <intrins.h>
#define TRUE 1 /* define logical true / false */
#define FALSE 0 /* values for bit variables */
#define SCROLL_DELAY 2000 /* scroll delay */
#define TIMER0_COUNT 0xFADA // 1.1ms
void delay_us(unsigned int d);
typedef unsigned char byte; /* type define objects with */
typedef unsigned int word; /* more classical microprocessor */
code unsigned char matrix[59][6]=
{0x00,0x00,0x00,0x00,0x00,0x00, //space
0x00,0x00,0x7d,0x00,0x00,0x00, //!
0x00,0x60,0x00,0x60,0x00,0x00, //"
0x14,0x7f,0x14,0x7f,0x14,0x00, //#
0x32,0x49,0x7f,0x49,0x26,0x00, //$
0x62,0x64,0x08,0x13,0x23,0x00, //%
0x36,0x49,0x35,0x02,0x05,0x00, //&
0x00,0x00,0x00,0x50,0x60,0x00, //'
0x1c,0x22,0x41,0x00,0x00,0x00, //(
0x00,0x00,0x41,0x22,0x1c,0x00, //)
0x2a,0x1c,0x3e,0x1c,0x2a,0x00, //*
0x08,0x08,0x3e,0x08,0x08,0x00, //+
0x00,0x01,0x02,0x00,0x00,0x00, //,
0x08,0x08,0x08,0x08,0x08,0x00, //-
0x00,0x00,0x01,0x00,0x00,0x00, //.
0x02,0x04,0x08,0x10,0x20,0x00, ///
0x3e,0x45,0x49,0x51,0x3e,0x00, //0
0x00,0x21,0x7f,0x01,0x00,0x00, //1
0x27,0x49,0x49,0x49,0x31,0x00, //2
0x22,0x49,0x49,0x49,0x36,0x00, //3
0x0c,0x14,0x24,0x7f,0x04,0x00, //4
0x7a,0x49,0x49,0x49,0x46,0x00, //5
0x3e,0x49,0x49,0x49,0x26,0x00, //6
0x41,0x42,0x44,0x48,0x70,0x00, //7
0x36,0x49,0x49,0x49,0x36,0x00, //8
0x32,0x49,0x49,0x49,0x3e,0x00, //9
0x00,0x00,0x22,0x00,0x00,0x00, //:
0x00,0x01,0x22,0x00,0x00,0x00, //;
0x08,0x14,0x22,0x41,0x00,0x00, //<
0x14,0x14,0x14,0x14,0x14,0x00, //=
0x00,0x41,0x22,0x14,0x08,0x00, //>
0x20,0x40,0x45,0x48,0x30,0x00, //?
0x3e,0x41,0x4d,0x4d,0x39,0x00, //@
0x1f,0x24,0x44,0x24,0x1f,0x00, //A
0x7f,0x49,0x49,0x49,0x36,0x00, //B
0x3e,0x41,0x41,0x41,0x22,0x00, //C
0x7f,0x41,0x41,0x22,0x1c,0x00, //D
0x7f,0x49,0x49,0x49,0x41,0x00, //E
0x7f,0x48,0x48,0x48,0x40,0x00, //F
0x3e,0x41,0x41,0x45,0x26,0x00, //G
0x7f,0x08,0x08,0x08,0x7f,0x00, //H
0x00,0x41,0x7f,0x41,0x00,0x00, //I
0x42,0x41,0x41,0x7e,0x40,0x00, //J
0x7f,0x08,0x14,0x22,0x41,0x00, //K
0x7f,0x01,0x01,0x01,0x01,0x00, //L
0x7f,0x20,0x18,0x20,0x7f,0x00, //M
0x7f,0x10,0x08,0x04,0x7f,0x00, //N
0x3e,0x41,0x41,0x41,0x3e,0x00, //O
0x7f,0x48,0x48,0x48,0x30,0x00, //P
0x3c,0x42,0x46,0x42,0x3d,0x00, //Q
0x7f,0x48,0x4c,0x4a,0x31,0x00, //R
0x32,0x49,0x49,0x49,0x26,0x00, //S
0x40,0x40,0x7f,0x40,0x40,0x00, //T
0x7e,0x01,0x01,0x01,0x7e,0x00, //U
0x78,0x06,0x01,0x06,0x78,0x00, //V
0x7f,0x02,0x0c,0x02,0x7f,0x00, //W
0x63,0x14,0x08,0x14,0x63,0x00, //X
0x60,0x10,0x0f,0x10,0x60,0x00, //Y
0x43,0x45,0x49,0x51,0x61,0x00};//Z
code char TEST_MSG[]="WELCOME TO BANGKOK $";
sbit LED_RCK = P1^1;
sbit LED_SRCK = P1^0;
sbit LED_SRCLK_H = P1^3;
sbit LED_DATA = P1^4;
sbit LED_G_L = P1^2;
//sbit LED_RESET = P3^4;
bit timer0_tick;
/*
use the free-running I timer to multiplex the led displays
*/
void delay_us(unsigned int d){
unsigned int i,m;
m=d/14;
for(i=0;i<m;i++);
}
void clock_shift (void) {
LED_RCK = 1;
delay_us(200);
LED_RCK = 0;
delay_us(200);
}
void main(void)
{
int i,j;
unsigned char row;
unsigned char *dataPtr, *tmpDataPtr;
unsigned char messageLength, currentChar, charOffset, tmpCurrentChar, tmpCharOffset;
char msg[32]; // ram for message max length
unsigned char ledArray[40];
P0=0x00;
P3=0x00;
P2=0x00;
LED_SRCLK_H=1;
LED_G_L=0;
/*
main execution loop, executes forever.
*/
//LED_RESET = 0;
LED_RCK = 0;
//LED_RESET = 1;
P0=0;
while(1){
for(i=0;i<sizeof(TEST_MSG);i++) msg[i]=TEST_MSG[i];
for(i=0;i<48;i++) if(msg[i]=='$') break; //calculate length of msg
messageLength = i;
charOffset = 0;
currentChar = 0;
dataPtr = &matrix[msg[0] - 0x20][0];
row = 0x01;
// this loop is the heart of the scroll
// message is scrolled until a key is hit on the keyboard
while (1) {
// load led array
//0x1f,0x24,0x44,0x24,0x1f,0x00
tmpDataPtr = dataPtr;
tmpCharOffset = charOffset;
tmpCurrentChar = currentChar;
for (i = 0; i <= 31; i++) {
ledArray[i] = *tmpDataPtr++;
if (++tmpCharOffset==0x06) {
tmpCharOffset = 0;
if (++tmpCurrentChar == messageLength)
tmpCurrentChar = 0;
tmpDataPtr = &matrix[msg[tmpCurrentChar] - 0x20][0];
}
}
if (++charOffset == 0x06) {
charOffset = 0;
if (++currentChar == messageLength)
currentChar = 0;
}
dataPtr = &matrix[msg[currentChar] - 0x20][charOffset];
// display led array
//row = 1;
for (j = 0;j <= SCROLL_DELAY; j++) {
for (i = 0; i <= 10; i++) {
LED_DATA = (ledArray[i] & row) ? 1 : 0; //invert image by interchng 0:1
clock_shift() ;
}
LED_G_L=1;
delay_us(200);
LED_SRCK=1;
delay_us(200);
LED_SRCK=0;
delay_us(200);
//P0 = row;
P0=row;
delay_us(1000);
row <<= 1; // next line to be switched on
if (row==0x80){
row = 0x01; // if last line go back to the first line
delay_us(1000);
P0 = 0x00; }
LED_G_L=0;
delay_us(200);
}
}//while
}//while
}//----------------end main
this code is not work
Result
Please help me.