int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600); // 啟動通訊 (你須開啟 Serial Monitor 序列埠監視器或稱串口監視器)
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin); // 讀取 sensorPin 類比腳的值 0 ~ 1023
Serial.print( sensorValue ); // 印到串口監視器
Serial.println(" I am 你的學號 你的英文姓名(自己拼音)");
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for milliseconds:
delay(sensorValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for milliseconds:
delay(sensorValue); // 關燈後也延遲 (Delay) 一下下
}