AT89C5X, 8 * Over 8 o'clock LED, display the demo code.

xiaoxiao2021-03-06  42

Corresponding hardware system: Hengji Electric-AVR-C51 Comprehensive Learning Board MCU Type: C51 Development Environment: Keil C Is Heil Cerem The website: http://www.hejoin.com/

The program is I wrote very early. For reference only. .

#include

const char mytext [] [8] = {{0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0x81, 0x81}, // L {0xC3, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XC3}, / / I {0x81, 0x81, 0xE7, 0xE7, 0xE4, 0XE4, 0XE1, 0XF3}, // j {0xC3, 0xE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0X3C3}, // i {0x3c, 0x3c, 0x38 0x30, 0x24, 0x0c, 0x1c, 0x3c}, // n {0x99, 0x99, 0x99, 0x99, 0x99}, // h {0XC3, 0X99, 0X99, 0X81, 0X81, 0X99, 0X99 , 0x99}, // a {0XC3, 0X99, 0X99, 0X99, 0X99, 0X99, 0X99, 0XC3} // o};

// 1 to 8 LED data tube address number or line number const char LED [] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; / * Unit output showbit: Select Output LED pipe lednum: data to be output * / void delay (unsigned char Times) {// does not accurately delay, error is large Unsigned Char i; for (; Times> 0; Times -) for (i = 0; I <255; I -);

Void Display (unsigned char showbit, ledtext) {p2_7 = 0; // 片 P0 = LED [Showbit-1]; // Which row is displayed on which row of P2_6 = 1; p2_6 = 0; // ------------ P0 = LEDText; // give P2_5 a pulse, the data display buffer will display p2_5 = 1; p2_5 = 0;} // -------- --------------------------- void showArray (unsigned char i) {unsigned char iCol = 0; int sc = 0; for (; SC) <= 3000; SC ) // The plus cycle is to make a penalty to display {IF (ICOL == 8) ICol = 0; Display (ICOL 1, MyText [IROW] [ICOL]); DELAY (20 ); ICOL ;}} // ------------------ void main (void) {unsigned char irow = 0;

While (1) {if (iRow == 8) iRow = 0; showarray (irow); delay (2000); delay (2000); iRow ; // Select the next word to display}}

转载请注明原文地址:https://www.9cbs.com/read-55905.html

New Post(0)