Code:
#include <avr/io.h> void disp(unsigned char col, unsigned char num); unsigned char image[] = {0xE7, 0x21, 0xCB, 0x6B, 0x2D, 0x6E, 0xEE, 0x23, 0xEF, 0x2F, 0xAF, 0xEC, 0xC6, 0xE9, 0xCE, 0x8E}; int main (void) { unsigned char ind; unsigned int num; DDRA = 0xFF; DDRC = 0xC3; num = 0x89AB; while(1){ disp(ind, (num / (0x0001 << (ind * 4))) & 0x0F); ind++; ind &= 3; } } void disp(unsigned char col, unsigned char num) { PORTC = 0xFF; PORTA = image[num]; if(col == 0) PORTC = ~(1 << 0); if(col == 1) PORTC = ~(1 << 1); if(col == 2) PORTC = ~(1 << 6); if(col == 3) PORTC = ~(1 << 7); }
các bác cho hỏi dòng:
Code:
disp(ind, (num / (0x0001 << (ind * 4))) & 0x0F);
cảm ơn các bác trước nhé
ps: xin lỗi vì thiếu mất cái hàm, he he ,sory các bác
Comment