Bỏ qua nội dung

Lesson 7: Analog input

English

More than on and off

  • The pins A0 to A5 can measure a voltage from 0 V to 5 V.
  • analogRead(A0) gives a number from 0 (0 V) to 1023 (5 V). 2.5 V gives about 512.
  • A potentiometer (a knob) or a light sensor gives a voltage. On this page, move the slider.
void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = analogRead(A0);
  Serial.println(value);
  delay(500);
}

Đăng nhập hoặc tạo tài khoản

IGCSE, A-Level & AP