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