본문 바로가기
임베디드/Atmega128

도트매트릭스 8x8 숫자 0~9 띄우기 / 흐르게 하기

by sj0020 2020. 12. 14.

https://blog.naver.com/dododokim/221368935252

 

도트 매트릭스로 숫자찍기

먼저 0의 모양을 배열에 나타내보면 이렇게 된다. 이 모양을 도트 매트릭스에 나타내야 하는데 소스에서는 ...

blog.naver.com

#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>

unsigned char arr[10][8]={
	{0xff, 0xff, 0x81, 0x7e, 0x7e, 0x81, 0xff, 0xff},
	{0xff, 0xff, 0x7b, 0x7d, 0x00, 0x7f, 0xff, 0xff},
	{0xff, 0xff, 0x1d, 0x6e, 0x76, 0x79, 0xff, 0xff},
	{0xff, 0xff, 0xbd, 0x76, 0x76, 0x89, 0xff, 0xff},
	{0xff, 0xe7, 0xeb, 0xed, 0x00, 0xef, 0xff, 0xff},
	{0xff, 0xff, 0x70, 0x76, 0x76, 0x8e, 0xff, 0xff},
	{0xff, 0xff, 0x83, 0x6d, 0x6e, 0x6e, 0x9d, 0xff},
	{0xff, 0xff, 0x7e, 0x9e, 0xe6, 0xf8, 0xff, 0xff},
	{0xff, 0xff, 0x89, 0x76, 0x76, 0x89, 0xff, 0xff},
	{0xff, 0xff, 0xb9, 0x76, 0x76, 0x81, 0xff, 0xff}
};

int i,j, time = 0;

int main (void)
{
	DDRF= DDRE = 0xFF; 
	
	while(1)
	{
		for(i=0;i<10;i++)
		{
			for(time=0;time<100;time++)
			{
				for(j=0;j<8;j++)
				{
					PORTE=0b00000001<<j;
					PORTF=arr[i][j];
					_delay_ms(1);
				}
			}
		}
	}
}			

#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>

unsigned char arr[10][8]={
	{0xff, 0xff, 0x81, 0x7e, 0x7e, 0x81, 0xff, 0xff},
	{0xff, 0xff, 0x7b, 0x7d, 0x00, 0x7f, 0xff, 0xff},
	{0xff, 0xff, 0x1d, 0x6e, 0x76, 0x79, 0xff, 0xff},
	{0xff, 0xff, 0xbd, 0x76, 0x76, 0x89, 0xff, 0xff},
	{0xff, 0xe7, 0xeb, 0xed, 0x00, 0xef, 0xff, 0xff},
	{0xff, 0xff, 0x70, 0x76, 0x76, 0x8e, 0xff, 0xff},
	{0xff, 0xff, 0x83, 0x6d, 0x6e, 0x6e, 0x9d, 0xff},
	{0xff, 0xff, 0x7e, 0x9e, 0xe6, 0xf8, 0xff, 0xff},
	{0xff, 0xff, 0x89, 0x76, 0x76, 0x89, 0xff, 0xff},
	{0xff, 0xff, 0xb9, 0x76, 0x76, 0x81, 0xff, 0xff}
};

int i,j, time = 0;

int main (void)
{
	DDRF= DDRE = 0xFF; 
	
	while(1)
	{
		for(i=0;i<10;i++)
		{
			
			//for(time=0;time<100;time++)
			//{
				for(j=0;j<8;j++)
				{
					PORTE=0b00000001<<j;
					PORTF=arr[i][j];
					_delay_ms(1);
				}
				_delay_ms(500);
		//	}
		}
	}
}