|
程序代碼: #include <avr/io.h> #include <avr/eeprom.h> #include <avr/pgmspace.h> #define F_CPU 1200000U #include <util/delay.h> #include "74HC595.h"
#define K1 (PINB&_BV(3))
/*const unsigned char NUM0TO7[] PROGMEM = { 0x0C, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0C, 0x00, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00, 0x0C, 0x12, 0x10, 0x08, 0x04, 0x02, 0x1E, 0x00, 0x0C, 0x12, 0x10, 0x0C, 0x10, 0x12, 0x0C, 0x00, 0x08, 0x0C, 0x0C, 0x0A, 0x0A, 0x1E, 0x08, 0x00, 0x1E, 0x02, 0x02, 0x0E, 0x10, 0x10, 0x0E, 0x00, 0x0C, 0x12, 0x02, 0x0E, 0x12, 0x12, 0x0C, 0x00, 0x1E, 0x12, 0x10, 0x08, 0x04, 0x04, 0x04, 0x00};*/
unsigned char display = 0x00;
/*unsigned char read(unsigned char pos) { if (pos < 64) return pgm_read_byte(NUM0TO7 + pos); else { eeprom_busy_wait(); return eeprom_read_byte((uint8_t *)pos); } }*/
int main(void) { DDRB = 0x17; // 00010111 PORTB = 0x1f; // 00011111 display = 0x7f; while (1) { HC595_SerIn(~display); HC595_ParOut(); /*if (display % 2 == 0) PORTB |= _BV(4); else PORTB &= ~_BV(4); _delay_ms(500); display++;*/ if (!K1) { _delay_ms(30); if (!K1) { display++; while (K1) _delay_ms(20); _delay_ms(200); } } } return 0; }
|