呼吸灯

呼吸灯

const int dwqPin=A0;
const int ledPin=9;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int dwqValue=analogRead(dwqPin);
  dwqValue=dwqValue/10;
  for(int i=0;i<=255;i+=5){
      analogWrite(ledPin,i);
      delay(dwqValue);
  }

  for(int i=255;i>=0;i-=5){
    analogWrite(ledPin,i);
    delay(dwqValue);
  }
}

posted @ 2022-10-23 13:10  new-code  阅读(51)  评论(0)    收藏  举报