/*

 * main.c

 *

 * Created: 2015-12-02 오후 4:25:33

 * Author : assist304

 */ 


#include <avr/io.h>

#include "_main.h"

#include "_adc.h"

#include "_glcd.h"


unsigned int Data_ADC0 = 0;


char Dis_Scr_IO_ON[]={"O"};

char Dis_Scr_IO_OFF[]={"X"};

char Dis_Scr1[]={"#$%&'()*+,-./0123456"};

char Dis_Scr2[]={"789:;<=>?@ABCDEFGHIJ"};

char Dis_Scr3[]={"KLMNOPQRSTUVWXYZ[]{}"};


void Port_init(void) // 포트 초기화 구문입니다.

{

PORTA = 0x00; DDRA = 0xFF; // PORTA 출력 LOW ,핀의 출력 설정

PORTB = 0xFF; DDRB = 0b11111111; // PORTB 출력 LOW ,핀의 출력 설정

PORTC = 0x00; DDRC = 0xF0; // PORTC 상위 4bit 입력, 하위 4bit 출력

PORTD = 0x80; DDRD = 0b10000000; // 핀의 입출력 설정

PORTE = 0x00; DDRE = 0xFF; // PORTE 출력 LOW ,핀의 출력 설정

PORTF = 0x00; DDRF = 0x00; // PORTE 출력 LOW ,핀의 출력 설정

}


void init_devices(void) // 초기화 할수를 여기에 넣습니다.

{

cli(); //disable all interrupts


Port_init(); // Port 초기화

Adc_init();

lcd_init();         // initialize GLCD

sei(); //re-enable interrupts

}


int main(void)

{

init_devices();

lcd_clear();

lcd_string(0,0,"====================");

while(1)

{

Data_ADC0 = Read_Adc_Data(0) / 10; // 아날로그 0번 포트 읽기

_delay_ms(200); // 딜레이 200ms

lcd_clear(); // 그래픽 LCD 클리어

ScreenBuffer_clear(); // 스크린 버퍼 클리어

lcd_string(0,0,"ADC0 Potentiometer"); // ADC0 Potentiometer 출력

GLCD_Rectangle(20,0,30,Data_ADC0); // 라인 게이지 출력

lcd_xy(1,0); GLCD_4DigitDecimal(Data_ADC0); // ADC0의 값을 출력

}

}

블로그 이미지

뭐해볼까

,