C\C++/임베디드 시스템

임베디드 시스템 LED 쉬프트 출력

sundori 2023. 11. 8. 23:16
/*
LED를 쉬프트하며 출력하는 프로그램
*/
#include <mega128.h>
#include <delay.h>
#include <stdio.h>

#define LED_CON *((unsigned char *)0X8000)

void main(void){
    int i;
    unsigned char buff = 0;
    DDRB = 0x00;
    MCUCR = 0X80;
    
    LED_CON = 0X00;
    
    buff = 0x01;
    while(1){
        for(i = 0; i < 8; i++){
            LED_CON = buff;
            delay_ms(500);
            buff <<= 1;
            if(!buff){
                buff = 0x01;
            }
        }
    }
}