AVR

아두이노 예제) LED 속도 가속 또는 랜덤화 하기 + 시리얼 통신까지

by 디케 posted Aug 04, 2012
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

아두이노 예제) LED 속도 가속 또는 랜덤화 하기 + 시리얼 통신까지


// 시리얼 통신 속도를 9600으로 설정하고 Serial.println(출력변수값) 으로 하면 된다.


int dspeed = 50;   

int value;


void setup() 

    {      

      Serial.begin(9600);  

      pinMode(13, OUTPUT);  

    }


void loop() 

     {

        dspeed = dspeed + 1;

        if(dspeed > 500)

          {

            dspeed =  0;

          }


       Serial.println(dspeed);


      digitalWrite(13, HIGH);   // set the LED on

      delay(dspeed);              // wait for a second

      digitalWrite(13, LOW);    // set the LED off

      delay(dspeed);              // wait for a second

    }