int val=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
val = analogRead(A0); //前面收到誤解,一直以爲是6.
Serial.print("ADC Value: ");
Serial.print(val);
Serial.print("\n");
delay(300);
}
通過串口可以看到,最暗時值最小爲0,最亮時最大爲1024。