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。