아두이노

PWM

iseohyun 2022. 1. 17.

목차

     

    #define PIN_PWM 9
    
    int brightness = 0;
    int step = 5;
    
    void setup() {
      pinMode(PIN_PWM, OUTPUT);
    }
    
    void loop() {
      analogWrite(PIN_PWM, brightness);
      
      brightness += step;
    
      if ((brightness >= 255)|| (brightness <= 0)) {
          step = -step;
      }
      
      delay(10);    // 10 milliseconds
    }

    출처 : https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fade

     

    Fade

    Open-source electronic prototyping platform enabling users to create interactive electronic objects.

    www.arduino.cc

     

    '아두이노' 카테고리의 다른 글

    3색 LED  (0) 2022.01.17
    8 x 8 dot Matrix  (0) 2022.01.17
    단순 버튼 입력  (0) 2022.01.17
    LED  (0) 2022.01.17
    건반 만들기  (0) 2022.01.17

    댓글