用Tinkercad学arduino之 读取电位器模拟输入

 

 

/*
  AnalogReadSerial
  Reads an analog input (potentiometer) on pin 0,
  prints the result to the serial monitor.

  OPEN THE SERIAL MONITOR TO VIEW THE OUTPUT FROM
  THE POTENTIOMETER >>

  Attach the center pin of a potentiometer to pin
  A0, and the outside pins to +5V and ground.

  This example code is in the public domain.
*/

int sensorValue = 0;

void setup()
{
  pinMode(A0, INPUT);
  Serial.begin(9600);

}

void loop()
{
  // read the input on analog pin 0:
  sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(10); // Delay a little bit to improve simulation performance
}

 

相关文章:

  • 2021-07-03
  • 2021-07-10
  • 2021-10-20
  • 2021-07-14
  • 2021-11-02
  • 2021-12-25
  • 2022-02-21
  • 2021-08-23
猜你喜欢
  • 2021-12-04
  • 2022-01-27
  • 2021-12-21
  • 2022-02-26
  • 2021-10-02
  • 2021-07-16
  • 2021-08-02
相关资源
相似解决方案