MCU Example——I LOVE U

Publisher:风轻迟Latest update time:2020-03-26 Source: eefocusKeywords:MCU  I  LOVE Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include

#include

 

typedef unsigned int u16;

typedef unsigned char u8;

 

sbit butt = P3^2; //Independent button, connected to external interrupt 0

 

sbit RCLK = P3^5;

bit SRCLK = P3^6;

sbit SER = P3^4; //HC595 chip

 

u8 code led_H[] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}; // dot matrix columns

u8 code ledL_I[] = {0x00,0x81,0x81,0xff,0xff,0x81,0x81,0x00}; //The set of rows of I

u8 code ledL_LOVE[] = {0x30,0x78,0xfe,0x7f,0x7f,0xfe,0x78,0x30}; //Collection of love

u8 code ledL_U[] = {0x00,0xff,0xff,0x03,0x03,0xff,0xff,0x00}; //Collection of U

 

u8 flag=0; // Flag flag = 0;

 

 

void delay(u16 i) //delay function

{

    while(i--);

}

 

void HC595(u8 dat) //HC595 chip

{

    u8 a;

    RCLK = 0;

    SRCLK = 0;         

    for(a=0;a<8;a++){

        SER = that>>7;

        dat <<= 1;

        SRCLK = 1;

        _nop_();

        _nop_();

        SRCLK = 0;      

    }

    RCLK = 1;

    _nop_();

    _nop_();

    RCLK = 0;

}

 

void Int0_init() //Prepare the parameters of external interrupt 0 in advance

{

    EA = 1;

    IT0 = 1;

    EX0 = 1;

}

 

void main() //Main function

{   

    Int0_init();

    while(1){

        u8 j;

        switch(flag){ //switch statement

              case 0:for(j=0;j<8;j++){

                       HC595(ledL_I[j]);

                       P0 = led_H[j];

                       delay(100);

                       HC595(0x00);

                       };break;

              case 1:for(j=0;j<8;j++){

                        HC595(ledL_LOVE[j]);

                        P0 = led_H[j];

                        delay(100);

                        HC595(0x00);

                        };break;

              case 2:for(j=0;j<8;j++){

                        HC595(ledL_U[j]);

                        P0 = led_H[j];

                        delay(100);

                        HC595(0x00);

                        };break;

        }

    }

}

 

void INT() interrupt 0

{   

    if(butt==0){

        delay(1000);

        if(butt==0){//button pressed

            if(flag<2) flag++;

            else flag=0;

        

        }

    }

}

 

// Status: I LOVE U (one appears each time you click the dot matrix)

Keywords:MCU  I  LOVE Reference address:MCU Example——I LOVE U

Previous article:MCU Example - Digital Tube Movement
Next article:Understanding of interruptions

Recommended ReadingLatest update time:2024-11-16 13:30

MCU A/D analog-to-digital conversion
First, let’s look at the AD574 function table: Hardware circuit diagram: Program flow chart: c program: /************************************************************************************************          The crystal oscillator selected in the A/D experiment program is 3MHz, the address Q0, Q1 is selecte
[Microcontroller]
MCU A/D analog-to-digital conversion
What is the difference between the microcontroller system clock and the real-time clock?
1. Most single-chip microcomputers have only one system clock. It is the driving source of each beat of the CPU. This frequency is generally several MHz. The speed is relatively fast, and its purpose is nothing more than to make the single-chip microcomputer work faster. Why is it not the number of GHz? This is determ
[Microcontroller]
The difference between the implementation of TCP/IP in single chip microcomputer and UNIX
TCP/IP was first implemented in the UNIX system, and later LINUX, DOS, and WINDOWS also implemented TCP/IP. Subsequently, the TCP/IP protocol was also ported to other embedded processors, such as the 8-bit MCS51 microcontroller, AVR microcontroller, 16-bit ARM, C166, and 32-bit MIPS, ARM and other chips. The bottom lay
[Microcontroller]
Design of Remote Fingerprint Collection Terminal Based on Single Chip Microcomputer
1 Introduction Fingerprints refer to the uneven lines on the front of the skin at the end of the finger. Although fingerprints are only a small part of human skin, they contain a lot of information. The lines of each person's fingerprint are different in pattern, breakpoints and intersections. Fingerprint recog
[Microcontroller]
Design of Remote Fingerprint Collection Terminal Based on Single Chip Microcomputer
1602 AVR MCU version of alarm indication function
Using ATMEGA16 chip Functional description: In normal state, 8 LEDs flash continuously and 1602 displays normal indication                 In the alarm state, all 8 LEDs are on without flashing, 1602 displays alarm, and the alarm can only be cleared by pressing the reset button.                In alarm state, it
[Microcontroller]
1602 AVR MCU version of alarm indication function
AVR microcontroller controls light emitting diodes
Light up an LED on the ARV MCU development board Schematic diagram:   Analysis: The screenshot above is the connection schematic diagram of the microcontroller and the LED light, where J6 is a resistor that limits the current to prevent the LED from burning out due to excessive current. The inside of the resist
[Microcontroller]
AVR microcontroller controls light emitting diodes
Design of smart home system based on single chip microcomputer
    1 Introduction   With the development of science and technology and the improvement of people's living standards, people have higher and higher requirements for convenient and fast living environment, and smart home system has emerged. Smart home is the product of the combination of modern electronic technology,
[Microcontroller]
Design of smart home system based on single chip microcomputer
1_5.1.6_U-boot analysis and use_uboot boot kernel_P
Now let's analyze how uboot starts the kernel. We know that the u-boot kernel startup is achieved through two instructions. nand read.jffs2 0x30007FC0 kernel; bootm 0x30007FC0 Reading the kernel nand read.jffs2 0x30007FC0 kernel Read the kernel from the kernel partition and put it at address 0x30007FC0. Part
[Microcontroller]
1_5.1.6_U-boot analysis and use_uboot boot kernel_P
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号