1.呼吸灯

void setup() {
  // put your setup code here, to run once:
  pinMode(10,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
for(int i=0,t=1;i<=255,i>=0;i=i+t){
  analogWrite(10,i);
  delay(8);
  if(i==255)
  t=-t;
  delay(8);
  }

}

  接线:二极管长脚接D10;短脚接GND

猜你喜欢

转载自www.cnblogs.com/Sonny-xby/p/11072709.html