아두이노 RGB_LED 소스코드

    아두이노 RGB_LED 소스코드

    #include <LiquidCrystal_I2C.h>
    
    LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,16,2);
    
    const int VR_PIN = A0;  // 0
    const int PWM_RED_PIN = 9;
    
    void setup() {
      // put your setup code here, to run once:
      lcd.init();
      lcd.begin(16, 2);
      lcd.clear();
      lcd.backlight();
      Serial.begin(115200UL);
      pinMode(VR_PIN, INPUT);
      pinMode(PWM_RED_PIN, OUTPUT);
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      int vr_value = analogRead(VR_PIN);
      
      vr_value = map(vr_value,0,1023,0,255);
      analogWrite(PWM_RED_PIN, vr_value);
      Serial.println(vr_value);
      Serial.println("PWM");
      lcd.setCursor(0,0);
      lcd.print(vr_value);
      lcd.print("PWM");
      delay(5000UL);
      lcd.clear();
    
    }

    '코딩 > Arduino(c++)' 카테고리의 다른 글

    아두이노 CDS 조도센서 소스코드  (0) 2019.11.28
    아두이노 ULTRA SONIC 소스코드  (0) 2019.11.27
    아두이노 Serial 처음 시작  (0) 2019.11.26
    이떄까지 해본 아두이노  (0) 2019.05.22
    아두이노 통신  (0) 2019.05.13

    댓글

    Designed by JB FACTORY