const int potPin = 4;
void setup() {
  // put your setup code here, to run once:
  pinMode(potPin,INPUT);
  Serial.begin(115200);
  Serial.println("hello world");
  analogSetWidth(10);
}
int val;
void loop() {
  val = analogRead(potPin);
  Serial.print("电位器的数值是:");
  Serial.println(val);
  delay(20);
}

4 条评论

  • 1