analogRead liefert 0–1023
Wandeln Sie eine Spannung in eine nutzbare Zahl um
analogRead liefert 0–1023 ist eine kostenlose Arduino & IoT Academy-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Arduino & IoT Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Turning Voltage into Numbers
Code cannot use raw volts directly. The analogRead function measures a pin and hands you back a plain number you can work with.
The Range Is 0 to 1023
Every analogRead result lands between 0 and 1023. That is exactly 1024 possible steps, from the lowest voltage to the highest.
Why 1024 Steps
The Uno uses a 10-bit converter, and 2 to the power of 10 is 1024. More bits would simply give you finer resolution.
0 Means Zero Volts
A reading of 0 means the pin sees 0V, the very bottom of the range. Nothing lower can be measured here.
1023 Means Full Voltage
A reading of 1023 means the pin is at the reference voltage, normally 5V on an Uno. That is the top of the scale.
Halfway Is About 512
Around 2.5V the value sits near 512, the middle of the range. The mapping from voltage to number is wonderfully linear.
Call It on an Analog Pin
Pass an analog pin name to read it. analogRead(A0) samples pin A0 and returns its current value as an int.
int value = analogRead(A0);Store It in an int
The result fits easily in an int, since 1023 is small. Save it to a variable so you can use it later in your code.
int sensor = analogRead(A0);No pinMode Needed
Analog inputs are ready out of the box. You do not call pinMode for them, you simply call analogRead when you want a value.
Convert Back to Volts
To see actual voltage, scale the reading. Multiply by 5.0 and divide by 1023 to turn the number into volts.
float v = analogRead(A0) * 5.0 / 1023.0;Readings Wobble a Little
Tiny electrical noise makes values jiggle by a point or two. That is normal, and averaging a few reads smooths it out.
Quick Check
What does analogRead hand back to you?
Recap: The 0 to 1023 Scale
You learned analogRead turns a 0V to 5V signal into a number from 0 to 1023. Store it in an int, and scale it back to volts when needed.
Häufig gestellte Fragen
Ist die Lektion „analogRead liefert 0–1023“ kostenlos?
Ja — der vollständige Text von „analogRead liefert 0–1023“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Arduino & IoT Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Arduino & IoT Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „analogRead liefert 0–1023“?
Wandeln Sie eine Spannung in eine nutzbare Zahl um Du übst Arduino & IoT Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Arduino & IoT Academy zu starten?
Keine Vorkenntnisse erforderlich. Arduino & IoT Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.
Wie lange dauert die Lektion „analogRead liefert 0–1023“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Arduino & IoT Academy-Lektion Code schreiben und ausführen?
Ja. Jede Arduino & IoT Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Digitale und analoge Signale
- analogRead liefert 0–1023
- Einen Potenziometer-Drehknopf auslesen
- Werte mit map() auf einen neuen Bereich abbilden