Dot Matrix, ATmega128, AVR - 0228
Dot Matrix, ATmega128, AVR
[ 간략 설명 ]
◈ Dot Matrix, ATmega128, AVR
◈
Dot Matrix 표시
내용 넣기~~~~
◆◆ ATmega128 : Dot Matrix : 왼쪽으로 문자 흐름 표시 ◆◆
/*
Dot matrix ( 8x8 ) P.345
왼쪽으로 흐르는 알파벳 대문자 소문자
0228A_DotMatrix_p345.c
*/
#include <mega128.h>
#include <delay.h>
#define S 1
#define COUNT 40
typedef unsigned char U08;
U08 Col[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
U08 Row[6][8] = { { 0x18, 0x24, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x42 },
{ 0x7c, 0x42, 0x42, 0x7c, 0x42, 0x42, 0x42, 0x7c },
{ 0x1c, 0x22, 0x40, 0x40, 0x40, 0x40, 0x22, 0x1c },
{ 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78 },
{ 0x7e, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x7e },
{ 0x7e, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x40 } };
void main(void){
U08 Ch[8];
int i, j, k, l, m;
DDRA = 0xff; // RED 세로
DDRB = 0xff; // Comm 가로
while(1){
for( k = 0; k < 6 ; k++){
for( j = 0 ; j < COUNT ; j++){
for( i = 0 ; i < 8 ; i++){
PORTB = Col[i];
PORTA = Row[k][i];
delay_ms(S);
}//endfori
}//endforj
for( m = 0 ; m < 8 ; m++){
for( l = 0 ; l < COUNT ; l++){
for( i = 0 ; i < 8 ; i++){
Ch[m] = Row[k][i] << m;
PORTB = Col[i];
PORTA = Ch[m];
delay_ms(S);
}//endfori
}//endforl
delay_ms(S);
}//endform
}//endfork
}//endwhile
}//end main
◆◆ ATmega128 : Dot Matrix : A-B-C-D-E-F 표시 ◆◆
/*
Dot matrix ( 8x8 ) P.345 - 1
왼쪽으로 흐르는 알파벳 대문자 소문자
0228B_DotMatrix_p345-1.c
*/
#include <mega128.h>
#include <delay.h>
#define S 2
#define COUNT 30
int i, j, k = 0;
int Col[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
int Row[6][8] = { { 0x18, 0x24, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x42 }, // A
{ 0x7c, 0x42, 0x42, 0x7c, 0x42, 0x42, 0x42, 0x7c }, // B
{ 0x1c, 0x22, 0x40, 0x40, 0x40, 0x40, 0x22, 0x1c }, // C
{ 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78 }, // D
{ 0x7e, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x7e }, // E
{ 0x7e, 0x40, 0x40, 0x7c, 0x40, 0x40, 0x40, 0x40 } // F
};
void main(void){
DDRA = 0xff; // RED 세로
DDRB = 0xff; // Comm 가로
//DDRC = 0xff; // Green 세로
while(1){
for( k = 0; k < 6 ; k++){
for( j = 0 ; j < COUNT ; j++){
for( i = 0 ; i < 8 ; i++){
PORTB = Col[i];
PORTA = Row[k][i];
delay_ms(S);
}//endfori
i = 0;
}//endforj
j = 0;
}//endfork
k = 0;
}//endwhile
}//end main
◆◆ ATmega128 : Dot Matrix : 알파벳 표시 ◆◆
/*
Dot Matrix P.341
대소문자 출력
0228C_DotMatrix_p341.c
*/
#include <mega128.h>
#include <delay.h>
#define S 2
#define COUNT 30
int Comm[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
int i,j,k = 0;
int Dot[53][8] = {{0x18,0x24,0x42,0x42,0x7e,0x42,0x42,0x42}, // A
{0x7c,0x42,0x42,0x7c,0x42,0x42,0x42,0x7c}, // B
{0x3c,0x42,0x42,0x40,0x40,0x42,0x42,0x3c}, // C
{0x78,0x44,0x42,0x42,0x42,0x42,0x44,0x78}, // D
{0x7e,0x40,0x40,0x7e,0x40,0x40,0x40,0x7e}, // E
{0x7e,0x40,0x40,0x7e,0x40,0x40,0x40,0x40}, // F
{0x3c,0x42,0x42,0x40,0x4e,0x42,0x42,0x3c}, // G
{0x42,0x42,0x42,0x7e,0x42,0x42,0x42,0x42}, // H
{0x1c,0x08,0x08,0x08,0x08,0x08,0x08,0x1c}, // I
{0x1c,0x08,0x08,0x08,0x08,0x08,0x28,0x10}, // J
{0x44,0x48,0x50,0x60,0x60,0x50,0x48,0x44}, // K
{0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7e}, // L
{0x42,0x66,0x5a,0x42,0x42,0x42,0x42,0x42}, // M
{0x42,0x62,0x52,0x4a,0x46,0x42,0x42,0x42}, // N
{0x3c,0x42,0x42,0x42,0x42,0x42,0x42,0x3c}, // O
{0x7c,0x42,0x42,0x42,0x7c,0x40,0x40,0x40}, // P
{0x3c,0x42,0x42,0x42,0x42,0x4a,0x46,0x3e}, // Q
{0x7c,0x42,0x42,0x7c,0x50,0x48,0x44,0x42}, // R
{0x3c,0x42,0x40,0x3c,0x02,0x02,0x42,0x3c}, // S
{0x3e,0x08,0x08,0x08,0x08,0x08,0x08,0x08}, // T
{0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3c}, // U
{0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18}, // V
{0x42,0x42,0x42,0x42,0x42,0x42,0x5a,0x24}, // W
{0x42,0x42,0x24,0x18,0x18,0x24,0x42,0x42}, // X
{0x22,0x22,0x22,0x14,0x08,0x08,0x08,0x08}, // Y
{0x7e,0x02,0x04,0x08,0x10,0x20,0x40,0x7e}, // Z
{0x00,0x00,0x18,0x04,0x1c,0x24,0x24,0x1a}, // a
{0x00,0x00,0x20,0x20,0x38,0x24,0x24,0x58}, // b
{0x00,0x00,0x00,0x18,0x24,0x20,0x24,0x18}, // c
{0x00,0x00,0x04,0x04,0x1c,0x24,0x24,0x1a}, // d
{0x00,0x00,0x00,0x18,0x24,0x3c,0x20,0x18}, // e
{0x00,0x00,0x08,0x14,0x10,0x38,0x10,0x10}, // f
{0x00,0x00,0x18,0x24,0x24,0x1c,0x04,0x18}, // g
{0x00,0x00,0x20,0x20,0x28,0x34,0x24,0x24}, // h
{0x00,0x00,0x08,0x00,0x08,0x08,0x08,0x08}, // i
{0x00,0x00,0x08,0x00,0x08,0x08,0x28,0x10}, // j
{0x00,0x00,0x20,0x24,0x28,0x30,0x28,0x24}, // k
{0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08}, // l
{0x00,0x00,0x00,0x54,0x2a,0x2a,0x2a,0x2a}, // m
{0x00,0x00,0x00,0x2c,0x12,0x12,0x12,0x12}, // n
{0x00,0x00,0x00,0x18,0x24,0x24,0x24,0x18}, // o
{0x00,0x00,0x38,0x24,0x24,0x38,0x20,0x20}, // p
{0x00,0x00,0x1c,0x24,0x24,0x1c,0x04,0x04}, // q
{0x00,0x00,0x00,0x2c,0x30,0x20,0x20,0x20}, // r
{0x00,0x00,0x18,0x24,0x10,0x08,0x24,0x18}, // s
{0x00,0x00,0x00,0x10,0x38,0x10,0x10,0x18}, // t
{0x00,0x00,0x00,0x00,0x24,0x24,0x24,0x1a}, // u
{0x00,0x00,0x00,0x00,0x22,0x22,0x14,0x08}, // v
{0x00,0x00,0x00,0x00,0x2a,0x2a,0x2a,0x14}, // w
{0x00,0x00,0x00,0x22,0x14,0x08,0x14,0x22}, // x
{0x00,0x00,0x00,0x22,0x14,0x08,0x10,0x20}, // y
{0x00,0x00,0x00,0x3e,0x04,0x08,0x10,0x3e}, // z
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; // SPACE
void main(void)
{
DDRA = 0xff; // RED 세로
DDRB = 0xff; // COMM 가로
DDRC = 0xff; // GREEN 세로
while(1){
for(j=0; j<53; j++){
for(k=0; k<COUNT; k++){
for(i=0; i<8; i++){
PORTB = Comm[i];
PORTA = Dot[j][i];
delay_ms(S);
}//endfori
i=0;
}//endfork
k=0;
}//endforj
j=0;
}//endwhile
}//end main
◆◆ ATmega128 : Dot Matrix : 스위치 & FND & Dot Matrix 연동 ◆◆
/*
Dot Matrix P.347
스위치 & FND & Dot Matrix 연동
1. SW8 - FND U3, U4
2. SW14 - FND U5, U6
3. Dot Matrix 에 합을 표시
0228D_DotMatrix_p347.c
*/
#include <mega128.h>
#include <delay.h>
int i, j, k, l, m , S, Sum1, Sum10 = 0;
char Seg[10] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f }; // 7-SGE 배열
int Dot1[10][8] = {{0x00, 0x00, 0x00, 0x07, 0x05, 0x05, 0x05, 0x07},
{0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01},
{0x00, 0x00, 0x00, 0x07, 0x01, 0x07, 0x04, 0x07},
{0x00, 0x00, 0x00, 0x07, 0x01, 0x07, 0x01, 0x07},
{0x00, 0x00, 0x00, 0x05, 0x05, 0x07, 0x01, 0x01},
{0x00, 0x00, 0x00, 0x07, 0x04, 0x07, 0x01, 0x07},
{0x00, 0x00, 0x00, 0x07, 0x04, 0x07, 0x05, 0x07},
{0x00, 0x00, 0x00, 0x07, 0x05, 0x01, 0x01, 0x01},
{0x00, 0x00, 0x00, 0x07, 0x05, 0x07, 0x05, 0x07},
{0x00, 0x00, 0x00, 0x07, 0x05, 0x07, 0x01, 0x07}};
int Dot10[10][8] = {{0x00, 0x00, 0x00, 0x70, 0x50, 0x50, 0x50, 0x70},
{0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10},
{0x00, 0x00, 0x00, 0x70, 0x10, 0x70, 0x40, 0x70},
{0x00, 0x00, 0x00, 0x70, 0x10, 0x70, 0x10, 0x70},
{0x00, 0x00, 0x00, 0x50, 0x50, 0x70, 0x10, 0x10},
{0x00, 0x00, 0x00, 0x70, 0x40, 0x70, 0x10, 0x70},
{0x00, 0x00, 0x00, 0x70, 0x40, 0x70, 0x50, 0x70},
{0x00, 0x00, 0x00, 0x70, 0x50, 0x10, 0x10, 0x10},
{0x00, 0x00, 0x00, 0x70, 0x50, 0x70, 0x50, 0x70},
{0x00, 0x00, 0x00, 0x70, 0x50, 0x70, 0x10, 0x10}};
int Comm[8] = { 0x01, 0x02,0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
void main(void)
{
DDRA = 0xff;
DDRB = 0xff;
DDRC = 0xff;
DDRF = 0xff;
while(1){
EICRB = 0b10101010;
EIMSK = 0b11110000;
SREG = 0x80;
PORTF = 0b11100000;
PORTB = Seg[i];
if( i >=10 ) i = 0, k++;
delay_ms(2);
PORTF = 0b11010000;
PORTB = Seg[k];
if( k >=10 ) k = 0;
delay_ms(2);
PORTF = 0b10110000;
PORTB = Seg[j];
if( j >= 10 ) j = 0, l++;
delay_ms(2);
PORTF = 0b01110000;
PORTB = Seg[l];
if( l >=10 ) l = 0;
delay_ms(2);
PORTF = 0b11110000;
Sum1 = S;
if(Sum1 == 10) S = 0, Sum10++;
if(Sum10 == 10 ) Sum10 = 0;
for( m = 0 ; m <8 ; m++){
PORTA = Dot1[Sum1][m];
PORTC = Comm[m];
delay_ms(1);
PORTA = 0x00;
}//endform
for( m = 0; m < 8 ; m++){
PORTA = Dot10[Sum10][m];
PORTC = Comm[m];
delay_ms(1);
PORTA = 0x00;
}//endform
}//end while
}//end main
interrupt [EXT_INT4] void Ex_int4(void){
i++, S++;
}//end4
interrupt [EXT_INT5] void Ex_int5(void){
j++, S++;
}//end5
'Edu > 유비쿼터스설비제어과정' 카테고리의 다른 글
LCD 문자열 출력, ATmega128, AVR - 0310 (0) | 2011.03.10 |
---|---|
Timer Couter, TC1, TIM1_COMPC, ATmega128, AVR - 0309 (0) | 2011.03.09 |
Timer Count, TC 1.3, AVR, ATmega128 - 0308 (0) | 2011.03.08 |
Timer Count , ATmega128, AVR - 3034 (2) | 2011.03.04 |
Timer Count, AVR, ATmega128 - 0302 (0) | 2011.03.02 |
Dot Matrix, 8 x 8 , ATmega128 - 0224 (0) | 2011.02.24 |
Dot Matrix, AVR, ATmega128 - 0223 (2) | 2011.02.23 |
전자사이크로회로, 미분회로, 4017 - 0222 (0) | 2011.02.22 |
미_ 채널전환회로, 디지털회로, RS래치 펄스 발생회로, 카운터회로, 디코더회로, 비안정 발진회로 및 스피커 구동회로 - 0221 (0) | 2011.02.21 |
ATmega128 : Stepping Motor, 정회전, 역회전 - 0218 (0) | 2011.02.18 |