#include "reg52.h" #include "intrins.h" #include <stdio.h> typedef unsigned int u16; typedef unsigned char u8; typedef unsigned int uint; typedef unsigned char uchar; #define LED_PORT P2 #define SMG_A_DP_PORT P0 u8 gsmg_code[17] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71}; void delayms(u16 ten_us) { while (ten_us--) ; } sbit led1 = P2 ^ 3; sfr LED = 0xA0; void main() { // led1 = 0; // u8 i = 0; // LED_PORT = ~0x01; // uchar aa = 0xfe; uchar aa = 0x7f; while (1) { LED = aa; delayms(50000); aa = _cror_(aa, 1); if (aa == 0xfe) { while (1) { LED = aa; delayms(50000); aa = _crol_(aa, 1); if (aa == 0x7f) { break; } } } // aa = _crol_(aa, 1); // led1 = 0; // delayms(50000); // led1 = 1; // delayms(50000); // for (i = 0; i < 4; i++) // { // led1 = 0; // delayms(50000); // led1 = 1; // // LED_PORT = _crol_(LED_PORT, 2); // // printf("LED_PORT = %x\n", LED_PORT) // delayms(50000); // } // for (i = 0; i < 4; i++) // { // // LED_PORT = _cror_(LED_PORT, 2); // // printf("LED_PORT = %x\n", LED_PORT) // delayms(50000); // } // SMG_A_DP_PORT = gsmg_code[0]; } }
标签:aa,50000,delayms,LED,单片机,51,跑马灯,led1,PORT From: https://www.cnblogs.com/dogingate/p/17546861.html