0Pricing
Arduino & IoT Academy · Lección

analogRead devuelve 0–1023

Convierta un voltaje en un número que pueda utilizar

analogRead devuelve 0–1023 es una lección gratuita de Arduino & IoT Academy en CoddyKit. Esta es la lección 2 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Arduino & IoT Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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.

Preguntas frecuentes

¿La lección «analogRead devuelve 0–1023» es gratis?

Sí — el texto completo de «analogRead devuelve 0–1023» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Arduino & IoT Academy, actualiza a CoddyKit PRO. El curso de Arduino & IoT Academy incluye 4 lecciones en total.

¿Qué aprenderé en «analogRead devuelve 0–1023»?

Convierta un voltaje en un número que pueda utilizar Practicas Arduino & IoT Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar Arduino & IoT Academy?

No se requiere experiencia previa. Arduino & IoT Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 2 de 4.

¿Cuánto tiempo toma la lección «analogRead devuelve 0–1023»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de Arduino & IoT Academy?

Sí. Cada lección de Arduino & IoT Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Señales digitales frente a analógicas
  2. analogRead devuelve 0–1023
  3. Lea el mando de un potenciómetro
  4. Asigne valores a un rango nuevo con map()
← Volver a Arduino & IoT Academy