以下為Arduino Uno板的Potentiometer實驗
需要材料:
Wire: n個
330Ω Resistor: 一個
LED: 一個
Potentiometer: 一個(不限電駔大小)
Arduino Uno: 一個
電路圖(Circuit diagram)

程式碼(Code)
int potPin = 3;
int ledPin = 9;
void setup() {
Serial.begin(9600); //這題沒設pinMode(腳位,(OUT or IN)PUT)
// pinMode(potPin,INPUT)
// pinMode(ledPin,OUTPUT)
}
void loop() {
int sensorValue = analogRead(potPin);
//讀取potPin接收到的值,以sensorValue表示
Serial.println(sensorValue,DEC); // 如果將()內的sensorValue/4會?,不使用DEC會?
sensorValue = sensorValue/4;
analogWrite(ledPin,sensorValue);
delay(50);
}
參考網站:
Lab4 Potentiometer:
http://coopermaa2nd.blogspot.tw/2010/12/arduino-lab4.html.html
參考對象:
