目前共有3篇帖子。
[展示]ATtiny13 + 2 × 74HC595驅動8x8點陣
1楼 巨大八爪鱼 2015-7-19 16:31
2楼 巨大八爪鱼 2015-7-19 16:33
程序代碼:
#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;
}
3楼 巨大八爪鱼 2015-7-19 17:00
顯示一條斜線:
while (1) {for (i = 0; i < 8; i++)
    {
    HC595_SerIn(~_BV(i));
    HC595_ParOut();
    HC595_SerIn(~_BV(i));
    HC595_ParOut();
    _delay_us(500);
    HC595_SerIn(0xff);
    HC595_ParOut();
    }}

回复帖子

内容:
用户名: 您目前是匿名发表
验证码:
 
 
©2010-2024 Arslanbar [手机版] [桌面版]
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。