int potpin=0;//设置模拟端口A0
int ledpin=11;//设置数字端口11 ,后面用作PWM输出
int val=0;//声明变量val
void setup()
{
pinMode(ledpin,OUTPUT);//设置数字11为输出模式
}
void loop()
{
val=analogRead(potpin);//读取A0的模拟电压值,并赋值到val
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(val); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(val); // wait for a second
}
arduino 越亮小灯闪越快
最新推荐文章于 2024-08-29 16:24:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)