int i=6;
void setup() {
// put your setup code here, to run once:
pinMode(i,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
analogWrite(i,0);
delay(1000);
analogWrite(i,50);
delay(1000);
analogWrite(i,100);
delay(1000);
analogWrite(i,150);
delay(1000);
analogWrite(i,200);
delay(1000);
analogWrite(i,250);
delay(1000);
}
这里用到了analogWrite,参数一是引脚值,参数二是输出的电压值,最大是255V。这里有一个前提,输出的引脚只能是带波浪线的数字引脚,这样才能改变电压值