Page 248 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 248
void tv_on(){PORTB.2 = 1;}
void tv_off(){PORTB.2 = 0;}
void air_on(){PORTB.3 = 1;}
void air_off(){PORTB.3 = 0;}
void door_open()
{
if(tim0_cnt >= 2000) // 10us x 2000 = 20ms 주기 체크
{
tim0_cnt = 0;
PORTB.4 = 1; // 모터 High 출력
}
/* tim0_cnt가 1이면 10uS이다 54이면 540uS, mot_pos가 0이면
rc_time[mot_pos]가 54 즉
0.54mS(540uS)가 된다. */
if(tim0_cnt >= rc_time[0]) PORTB.4 = 0; // 모터 Low 출력
}
void door_close()
{
if(tim0_cnt >= 2000) // 10us x 2000 = 20ms 주기 체크
{
tim0_cnt = 0;
PORTB.4 = 1; // 모터 High 출력
}
/* tim0_cnt가 1이면 10uS이다 54이면 540uS, mot_pos가 0이면
rc_time[mot_pos]가 54 즉
- 241 -