利用8*8点阵实现蔡徐坤跳舞(代码来自B站)
首先是main.c内容:include <REGX52.H>include "delay.h"include "matrix.h"unsigned char code donghua[]={0x18,0x18,0x3D,0x5A,0x98,0x28,0x28,0x28,0x5A,0x5A,0x3C,0x18,0x18,0x28,0x18,0x08,0x30,0x18,0x3C,0x1C,0x18,0x18,0x18,0x08,0x30,0x98,0x7C,0x18,0x18,0x28,0x18,0x08,0x10,0x18,0x3C,0x3C,0x18,0x28,0x28,0x08,0x30,0x18,0x3C,0x3C,0x18,0x24,0x24,0x44,0x30,0x18,0x3C,0x38,0x18,0x28,0x24,0x44,0x18,0x0C,0x1E,0x1C,0x0C,0x14,0x24,0x44,0x00,0x30,0x18,0x3C,0x1C,0x38,0x28,0x44,0x00,0xC0,0x60,0xF0,0xF0,0x30,0x48,0x44,0x00,0x30,0x18,0x3C,0x1C,0x38,0x28,0x44,0x18,0x0C,0x1E,0x1C,0x0C,0x14,0x24,0x44,0x00,0x30,0x18,0x3C,0x1C,0x38,0x28,0x44,0x00,0xC0,0x60,0xF0,0xF0,0x30,0x48,0x44,0x00,0x30,0x18,0x3C,0x1C,0x38,0x28,0x44,0x18,0x0C,0x1E,0x1C,0x0C,0x14,0x24,0x44,0x00,0x30,0x18,0x3C,0x1C,0x38,0x28,0x44,0x00,0xC0,0x60,0xF0,0xF0,0x30,0x48,0x44,0x00,0x30,0x18,0x3C,0x1C,0x38,0x28,0x44,0x18,0x0C,0x1E,0x1C,0x0C,0x14,0x24,0x44,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,};int main(){unsigned char i,offset,count=0; void matrix_init(); while(1) { for(i=0;i<8;i++) { matrix_showcol(i,donghua[i+offset]); } count++; if(count>40) { count=0; offset+=8; if(offset>160) {offset=0;} } }}其次是delay.h内容:void delay(unsigned int xms){while(xms) { unsigned char x,y,z; x=1; y=2; z=2; do { do { while(--z); } while(--y); } while(--x); xms=xms-1;} }附带的delay.c内容:ifndef delay_hdefine delay_hvoid delay(unsigned int xms);endif