Notice
Recent Posts
Recent Comments
관리 메뉴

안까먹을라고 쓰는 블로그

LED 출력 본문

Embedded/Atmega128

LED 출력

YawnsDuzin 2012. 9. 1. 20:28

 

반응형

LEDLight Emitting Diode)는 일종의 반도체 PN 접합 다이오드로서 순방향 전류가 흐를 때 여기에 혼합된 불순물의 종류와 농도에 의해 여러 가지 파장의 빛을 낸다.

 

 

EX)

파장이 380nm ~ 770nm정도 범위인 가시광선을 출력하는 VLED(Visible Light Emitting Diode)

이보다 파장이 긴 적외선을 출력하는 IRED(Infrared Emitting Diode)

 

- Led 출력 프로그램

 

#include <avr/io.h>
#include "c:\AvrEdit\JJ128c\JJ128.h"

 

int main(void)
{

unsigned char i, LED;

  MCU_initialize();                             // initialize MCU
  Delay_ms(50);                                 // wait for system stabilization
  LCD_initialize();                             // initialize text LCD module

  LCD_string(0x80,"   LED OUTPUT   ");          // display title on text LCD
  LCD_string(0xC0,"                ");
  Beep();

 

  while(1)
    { for(i=1; i<=3; i++)   // blink all LED by 3 times
        { PORTC = 0xF0;                         // LED4~1 on
          Delay_ms(500);
          PORTC = 0x00;                         // LED4~1 off
          Delay_ms(500);
        }

      for(i=1, LED=0x10; i<=5; i++)  // shift left from LED1 to LED4
        { PORTC = LED;
          Delay_ms(200);
          LED <<= 1;
        }

      for(i=1, LED=0x80; i<=5; i++)  // shift right from LED4 to LED1
        { PORTC = LED;
          Delay_ms(200);
          LED >>= 1;
        }
    }
}

반응형
Comments