Experiment 8 LCD 8*8 dot matrix

Publisher:玉树琼花Latest update time:2017-01-06 Source: eefocusKeywords:LCD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. The control dot matrix displays red and green alternately, flashing three times from top to bottom and from left to right.

wiring:

P0 connects to J12, P1 connects to J20, P2 connects to J19

/**

1. The control dot matrix displays red and green alternately, flashing three times from top to bottom and from left to right.

**/

 

#include

 

unsignedchar code table_LeftRight[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};

unsignedchar code table_TopBottom[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

enum DisplayDirecte{

    Left2Right,

    Right2Left,

    Top2Bottom,

    Bottom2Top

};

 

void delay(void)

{

    unsignedchar i,j,k;

 

    for(k=10;k>0;k--)

    for(i=20;i>0;i--)

    for(j=248;j>0;j--);

 

}

 

/***********************************************************

    Display rules

***********************************************************/

void DisplayRule(enum DisplayDirecte displayDirecte,unsignedchar index){

    switch(displayDirecte){

       case Left2Right:

           P2=table_LeftRight[index];

           P0=0xff;

           P1=0xff;

       break;

 

       case Right2Left:

           P1=table_LeftRight[7-index];

           P0=0xff;

           P2=0xff;

       break;

      

       case Top2Bottom:

           P2=0x00;

           P1=0xff;

           P0=table_TopBottom[7-index];

       break;

      

       case Bottom2Top:

           P1=0x00;

           P2=0xff;

           P0=table_TopBottom[index];

       break;

    }

}

/***********************************************************

    Show 3 times

***********************************************************/

void Display3Time(enum DisplayDirecte displayDirecte){

    unsignedchar i,RepeatTime;

    for(RepeatTime=0;RepeatTime<3;RepeatTime++)//control the number of repetitions

    {

       for(i=0;i<8;i++)                  

       {

           DisplayRule(displayDirecte,i);

           delay();

       }

    }

}

void main(void)

{

    while(1)

    {

      

       Display3Time(Left2Right);

       Display3Time(Right2Left);

       Display3Time(Top2Bottom);

       Display3Time(Bottom2Top);

   }

}

 

2. Self-encoding, control LCD to display 0~F or some simple Chinese characters (red and green alternately displayed)

3./*****************************************************************************************

4.2. Self-encoding, control LCD to display 0~F or some simple Chinese characters (red and green alternately displayed)     

5.******************************************************************************************/

#include

#define Lenth 19

unsignedchar code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //column selection

 

unsignedchar code digittab[Lenth][8]={

 

{0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00},//0

 

{0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00},//1

 

{0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00},//2

 

{0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00},//3

 

{0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00},//4

 

{0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00},//5

 

{0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00},//6

 

{0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00},//7

 

{0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00},//8

 

{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00},//9

 

{0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00},//P

 

{0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00},//R

 

{0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00},//E

 

{0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00},//C

 

{0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00},//H

 

{0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00},//I

 

{0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00},//N

 

{0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00}, //

 

{0x18,0x24,0x42,0x21,0x42,0x24,0x18,0x00} //Heart shape

};

 

unsignedint timecount1 , timecount2;

 

unsignedchar cntx , cnty ;

 

void main(void)

{

  cnty=0;

   

  while(1)

  {

     if(cnty

    {

     P1=0xFF;

     P2=tab[cntx]; // Column line

     P0=digittab[cnty][cntx];   // 行线

    }

    else//green

    {

     P2=0xFF;

     P1=tab[cntx]; // Column line

     P0=digittab[cnty-Lenth][cntx];  // 行线

    }

 

   //Used to control the speed of dynamic scanning

    if(++timecount1>=50)

    {

     timecount1=0;

     if(++cntx>=8) cntx=0;

    }

 

   //Used to control the switching speed between moving characters

    if(++timecount2>=20000)

    {

     timecount2=0;

     if(++cnty>=Lenth*2)cnty=0;

    }

  }

 

}


Keywords:LCD Reference address:Experiment 8 LCD 8*8 dot matrix

Previous article:Experiment 9 Infrared Receiver Microcontroller Decoding
Next article:Experiment 2 8-bit adder design

Recommended ReadingLatest update time:2024-11-16 14:44

AVR microcontroller drives LCD1602
I have been learning how to use AVR microcontrollers these days, and I have also transplanted some function libraries that I used on 51 microcontrollers before. Today I am debugging LCD1602 and would like to share my experience with you. When performing read and write operations, if a higher crystal oscillator frequ
[Microcontroller]
Why continue to be optimistic about LG, which continues to lose money?
LCD panel prices continued to fall in the third quarter, which means LG Display may incur losses again. ● The peak shipping season is about to begin and demand for LCDs will also increase, which will help prices rise. ● Many manufacturers have expressed their intention to cut LCD production, which should increase pr
[Embedded]
Why continue to be optimistic about LG, which continues to lose money?
Samsung suspends LCD TV panel purchases as TV demand plummets in first half of 2022
Samsung Electronics is facing an oversupply of LCD panels and has reportedly suspended purchases of LCD panels from its suppliers until further notice, TheElec reported. Market watchers expected Samsung to procure about 54 million LCD panels for its smart TV division this year. However, Samsung cut its annual target
[Embedded]
LCD vs. DLP: Who will win?
Who will win the battle between LCD and DLP? It is predicted that the total output value of the domestic large-screen splicing wall market will approach 4 billion for the first time in 2010, and will also develop rapidly at an annual growth rate of 30%. The rapid development of the large-screen splicing industry has
[Analog Electronics]
Temperature plotter based on tinyAVR and Nokia3310 LCD
Introduction: Using the tinyAVR microcontroller in a 14-pin package, the Nokia3310 LCD, a liquid crystal display module widely used in mobile phones, and the popular single-bus 3-pin digital temperature sensor DS18B 20, a practical and interesting dual-mode temperature plotter that can read both readings and graphs is
[Microcontroller]
Temperature plotter based on tinyAVR and Nokia3310 LCD
STC8H Development (Ten): SPI driver Nokia5110 LCD (PCD8544)
Nokia5110 LCD I have a Nokia 5110 LCD that I bought a long time ago and it has been gathering dust in the cardboard box. Maybe it was given as a gift when I bought other accessories? It has been left there without any suitable use. Occasionally, when I see it, I always think about it when I have time. This is what i
[Microcontroller]
STC8H Development (Ten): SPI driver Nokia5110 LCD (PCD8544)
STM32 study notes (6.1): LCD display
1.        Basic Concepts of LCD/LCM The structure of Liquid Crystal Display (LCD) is to place liquid crystals between two parallel pieces of glass. There are many vertical and horizontal fine wires between the two pieces of glass. The rod-shaped crystal molecules are controlled to change direction by powering on or o
[Microcontroller]
[51 MCU STC89C52] Use of LCD1602 LCD screen
1. LCD1602 module 1. Pin description Pin 3: VL is the contrast adjustment terminal of the LCD. The contrast is the weakest when connected to the positive power supply, and the contrast is the highest when connected to the ground. If it is too high, "ghosting" will occur. The contrast can be adjusted through a 10K p
[Microcontroller]
[51 MCU STC89C52] Use of LCD1602 LCD screen
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号