AVR 따라하기 > 022 - [LED-20] 32비트 LED 좌우교대시프트

인기검색어 > 아두이노 센서 ATMEGA128

최신글 질문게시판 동영상강좌 가입하기

▼ BASIC4MCU 후원업체 신제품 정보 ▼

▲ BASIC4MCU 후원업체 신제품 정보 ▲

BASIC4MCU > AVR 따라하기

2015년 강좌 | 022 - [LED-20] 32비트 LED 좌우교대시프트

페이지 정보

작성자 키트 작성일17-08-23 14:38 조회1,921회 댓글0건

본문

3660040649_CTFeBcq0_25C125A625B825F1_25BE25F825C025BD.PNG3Ftype3Dw740

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//--------------------------------------------------------
// CVAVR
// [LED-20] 32비트 LED 좌우교대시프트
//--------------------------------------------------------
#include <mega128.h> 
#include <delay.h> 
//
void main(void){
    char i;
    unsigned long led;
    DDRA=0xFF; DDRB=0xFF; DDRC=0xFF; DDRD=0xFF;
    while(1){
        for(i=0;i<32;i++){
            led=0x00000001<<i;
            PORTA=led>>24; PORTB=(led>>16)&0xFF; PORTC=(led>>8)&0xFF; PORTD=led&0xFF;
            delay_ms(31);
        }
        for(i=0;i<32;i++){
            led=0x80000000>>i;
            PORTA=led>>24; PORTB=(led>>16)&0xFF; PORTC=(led>>8)&0xFF; PORTD=led&0xFF;
            delay_ms(31);
        }
    }
}
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//--------------------------------------------------------
// AVRStudio
// [LED-20] 32비트 LED 좌우교대시프트
//--------------------------------------------------------
#define  F_CPU 16000000UL // 16 MHz
#include <avr/io.h>
#include <util/delay.h>
//
int main(void){
    char i;
    unsigned long led;
    DDRA=0xFF; DDRB=0xFF; DDRC=0xFF; DDRD=0xFF;
    while(1){
        for(i=0;i<32;i++){
            led=0x00000001<<i;
            PORTA=led>>24; PORTB=(led>>16)&0xFF; PORTC=(led>>8)&0xFF; PORTD=led&0xFF;
            _delay_ms(31);
        }
        for(i=0;i<32;i++){
            led=0x80000000>>i;
            PORTA=led>>24; PORTB=(led>>16)&0xFF; PORTC=(led>>8)&0xFF; PORTD=led&0xFF;
            _delay_ms(31);
        }
    }
}
cs


 
//--------------------------------------------------------------------------------------
3660040649_JU4Kbz5L_25C125A625B825F1_25BE25F825C025BD.PNG3Ftype3Dw740


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//--------------------------------------------------------
// CVAVR
// [LED-20] 32비트 LED 좌우교대시프트
//--------------------------------------------------------
#include <mega128.h> 
#include <delay.h> 
//
void main(void){
    char i;
    unsigned long led;
    DDRA=0xFF; DDRB=0xFF; DDRC=0xFF; DDRD=0xFF;
    while(1){
        for(i=0;i<32;i++){
            led=0x00000001<<i;
            PORTA=~(led>>24); PORTB=(~(led>>16))&0xFF; PORTC=(~(led>>8))&0xFF; PORTD=(~led)&0xFF;
            delay_ms(31);
        }
        for(i=0;i<32;i++){
            led=0x80000000>>i;
            PORTA=~(led>>24); PORTB=(~(led>>16))&0xFF; PORTC=(~(led>>8))&0xFF; PORTD=(~led)&0xFF;
            delay_ms(31);
        }
    }
}
cs

1
2

댓글 : 0

조회수 : 1,921

등록된 댓글이 없습니다.

게시물 검색

AVR 따라하기 목록

게시물 검색


Privacy Policy
MCU BASIC ⓒ 2017
PC버전