int ledPin = 9; // LED连接到数字引脚9int analogPin = 3; //电位器连接到模拟引脚3int val = 0; //定义变量存以储读值void setup(){pinMode(ledPin,OUTPUT); //设置引脚为输出引脚}void loop(){val = analogRead(analogPin); //从输入引脚读取数值analogWrite(ledPin,val / 4); // 以val / 4的数值点亮LED(因为analogRead读取的数值从0到1023,而analogWrite输出的数值从0到255)}