Tutorial.AnalogInput History

Hide minor edits - Show changes to markup

June 03, 2010, at 01:15 PM by Equipo Traduccion -
June 03, 2010, at 01:14 PM by Equipo Traduccion -
Changed line 33 from:
 Demostración de entrada analógica leyendo de un sensor analógico conectado al pin analógico 0  
to:
 Demostración de entrada analógica. Se lee de un sensor analógico conectado al pin analógico 0  
Changed line 35 from:
 El tiempo que el LED estará encendido o apagado, dependerá del valor analógico obtenido con analogRead(). 
to:
 El tiempo que el LED estará encendido o apagado, dependerá del valor obtenido con analogRead(). 
Changed lines 38-43 from:
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 13
 * LED cathode (short leg) attached to ground
to:
 * Potenciómetro conectado al pin analógico 0
 * pin central del potenciómetro conectado al pin
 * el pin de un extremo (cualquiera) a masa
 * el otro a +5V
 * el ánodo del LED (patilla larga) conectado a la salida digital 13
 * el cátodo del LED  (patilla corta) conectado a masa
Changed lines 45-46 from:
 * Note: because most Arduinos have a built-in LED attached 
 to pin 13 on the board, the LED is optional.
to:
 * Nota: Como en la mayoría de las placas Arduino viene de fábrica un LED ligado al pin digital 13, el LED es opcional.
Changed lines 48-50 from:
 Created by David Cuartielles
 Modified 16 Jun 2009
 By Tom Igoe
to:
 Creado por David Cuartielles
 Modificado 16 Jun 2009
 por Tom Igoe
Changed line 52 from:
 This example code is in the public domain.
to:
 Este código de ejemplo es de dominio público.
Changed lines 58-61 from:

int sensorPin = 0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor

to:

int sensorPin = 0; // selecciona el pin de entrada para el potenciómetro int ledPin = 13; // selecciona el pin para el LED int sensorValue = 0; // variable para almacenar el valor que ofrece el sensor

Changed line 63 from:
  // declare the ledPin as an OUTPUT:
to:
  // declara el ledPin como salida (OUTPUT):
Changed line 68 from:
  // read the value from the sensor:
to:
  // lee el valor del sensor:
Changed line 70 from:
  // turn the ledPin on
to:
  // enciende el  ledPin
Changed line 72 from:
  // stop the program for <sensorValue> milliseconds:
to:
  // detiene el programa durante <sensorValue> milisegundos:
Changed line 74 from:
  // turn the ledPin off:        
to:
  // apaga el ledPin :        
Changed line 76 from:
  // stop the program for for <sensorValue> milliseconds:
to:
  // detiene el programa durante <sensorValue> milisegundos:
June 03, 2010, at 01:06 PM by Equipo Traduccion -
Changed lines 5-8 from:

Un potenciómetro es un elemento pasivo con un eje que proporciona una resistencia variable, la cual puede ser leida por una placa Arduino como un valor analógico. En este ejemplo, ese valor controlará la frecuencia con la parpadeará un LED

Conectamos 3 cables a la placa Arduino. El primero desde masa a uno de los pines extremos potenciómentro. El segundo, desde 5 voltios al otro pin extremo del potenciómetro . EL tercero desde el pin analógico 2 al pin medio del potenciómetro.

to:

Un potenciómetro es un elemento pasivo con un eje que proporciona una resistencia variable, la cual puede ser leida por una placa Arduino como un valor analógico. En este ejemplo, ese valor controlará la frecuencia con la que parpadeará un LED

Conectamos 3 cables a la placa Arduino. El primero desde masa a uno de los pines extremos del potenciómentro. El segundo, desde 5 voltios al otro pin extremo del potenciómetro . El tercero desde el pin analógico 2 al pin medio del potenciómetro.

Changed lines 17-19 from:

image developed using Fritzing. Para más ejemplos de circuitos, ver elFritzing project page

to:

image developed using Fritzing. Para más circuitos de ejemplo, ver Fritzing project page

Changed lines 32-36 from:
   Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13. 
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead(). 
to:

/* Entrada analógica

 Demostración de entrada analógica leyendo de un sensor analógico conectado al pin analógico 0  
 alternando entre encendido y apagado de un diodo(LED)  conectado al pin digital 13. 
 El tiempo que el LED estará encendido o apagado, dependerá del valor analógico obtenido con analogRead(). 
Changed line 37 from:
 The circuit:
to:

El circuito:

June 03, 2010, at 12:46 PM by Equipo Traduccion -
June 03, 2010, at 12:25 PM by Equipo Traduccion -
Changed lines 32-36 from:
to:
   Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13. 
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead(). 
Added lines 38-81:
 The circuit:
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 13
 * LED cathode (short leg) attached to ground

 * Note: because most Arduinos have a built-in LED attached 
 to pin 13 on the board, the LED is optional.

 Created by David Cuartielles
 Modified 16 Jun 2009
 By Tom Igoe

 This example code is in the public domain.

 http://arduino.cc/en/Tutorial/AnalogInput

 */

int sensorPin = 0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  

}

void loop() {

  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);          
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);                  

}

June 03, 2010, at 12:23 PM by Equipo Traduccion -
Changed lines 1-15 from:

Examples > Analog I/O

Analog Input

A potentiometer is a simple knob that provides a variable resistance, which we can read into the Arduino board as an analog value. In this example, that value controls the rate at which an LED blinks.

We connect three wires to the Arduino board. The first goes to ground from one of the outer pins of the potentiometer. The second goes from 5 volts to the other outer pin of the potentiometer. The third goes from analog input 2 to the middle pin of the potentiometer.

By turning the shaft of the potentiometer, we change the amount of resistence on either side of the wiper which is connected to the center pin of the potentiometer. This changes the relative "closeness" of that pin to 5 volts and ground, giving us a different analog input. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and we read 0. When the shaft is turned all the way in the other direction, there are 5 volts going to the pin and we read 1023. In between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.

Circuit

An analog input connected to analog input pin 0.

click the image to enlarge

to:

Ejemplos > E/S Analógica

Entrada Analógica

Un potenciómetro es un elemento pasivo con un eje que proporciona una resistencia variable, la cual puede ser leida por una placa Arduino como un valor analógico. En este ejemplo, ese valor controlará la frecuencia con la parpadeará un LED

Conectamos 3 cables a la placa Arduino. El primero desde masa a uno de los pines extremos potenciómentro. El segundo, desde 5 voltios al otro pin extremo del potenciómetro . EL tercero desde el pin analógico 2 al pin medio del potenciómetro.

Al girar el eje del potenciómetro, cambiamos el valor de la resistencia entre los pines de los extremos y el pin central del potenciómtro. Esto cambia la "cercanía" relativa del pin central a 5 Voltios y a masa, ofreciendo diferentes valores analógicos de entrada. Cuando giramos el eje a tope en un sentido, llegarán 0 voltios al pin central, y leeremos 0. Cuando giramos el eje a tope, pero en el otro sentido, llegarán 5 voltios al pin central y leeremos 1023. Entre medias, analogRead() retorna un número entre 0 y 1023 que es proporcional al valor del voltaje aplicado al pin central.

Circuito

Una entrada analógica conectada a un pin de entrada analógica click en la imagen para aumentar

Changed lines 17-22 from:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic

click the image to enlarge

to:

image developed using Fritzing. Para más ejemplos de circuitos, ver elFritzing project page

Esquema

click en la imagen para aumentar

Changed lines 28-29 from:

Code

to:

Código

February 23, 2010, at 07:53 PM by Tom Igoe -
Changed lines 33-58 from:
 /*
   Analog Input
  Demonstrates analog input by reading an analog sensor on analog pin 0 and
  turning on and off a light emitting diode(LED)  connected to digital pin 13. 
  The amount of time the LED will be on and off depends on
  the value obtained by analogRead(). 
  
  The circuit:
  * Potentiometer attached to analog input 0
  * center pin of the potentiometer to the analog pin
  * one side pin (either one) to ground
  * the other side pin to +5V
  * LED anode (long leg) attached to digital output 13
  * LED cathode (short leg) attached to ground
  
  * Note: because most Arduinos have a built-in LED attached 
  to pin 13 on the board, the LED is optional.
  
  
  Created by David Cuartielles
  Modified 16 Jun 2009
  By Tom Igoe
  
  http://arduino.cc/en/Tutorial/AnalogInput
  
  */
to:
Deleted lines 34-55:
 int sensorPin = 0;    // select the input pin for the potentiometer
 int ledPin = 13;      // select the pin for the LED
 int sensorValue = 0;  // variable to store the value coming from the sensor

 void setup() {
   // declare the ledPin as an OUTPUT:
   pinMode(ledPin, OUTPUT);  
 }

 void loop() {
   // read the value from the sensor:
   sensorValue = analogRead(sensorPin);    
   // turn the ledPin on
   digitalWrite(ledPin, HIGH);  
   // stop the program for <sensorValue> milliseconds:
   delay(sensorValue);          
   // turn the ledPin off:        
   digitalWrite(ledPin, LOW);   
   // stop the program for for <sensorValue> milliseconds:
   delay(sensorValue);                  
 }
August 27, 2009, at 08:46 PM by Tom Igoe -
Added lines 18-20:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

July 05, 2009, at 07:19 PM by Tom Igoe -
Changed lines 28-34 from:

[@ /*

  Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13. 
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead(). 
to:
Changed lines 57-63 from:
 The circuit:
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 13
 * LED cathode (short leg) attached to ground
to:
 int sensorPin = 0;    // select the input pin for the potentiometer
 int ledPin = 13;      // select the pin for the LED
 int sensorValue = 0;  // variable to store the value coming from the sensor
Changed lines 61-62 from:
 * Note: because most Arduinos have a built-in LED attached 
 to pin 13 on the board, the LED is optional.
to:
 void setup() {
   // declare the ledPin as an OUTPUT:
   pinMode(ledPin, OUTPUT);  
 }
Added lines 66-77:
 void loop() {
   // read the value from the sensor:
   sensorValue = analogRead(sensorPin);    
   // turn the ledPin on
   digitalWrite(ledPin, HIGH);  
   // stop the program for <sensorValue> milliseconds:
   delay(sensorValue);          
   // turn the ledPin off:        
   digitalWrite(ledPin, LOW);   
   // stop the program for for <sensorValue> milliseconds:
   delay(sensorValue);                  
 }
Changed lines 79-108 from:
 Created by David Cuartielles
 Modified 16 Jun 2009
 By Tom Igoe

 http://arduino.cc/en/Tutorial/AnalogInput

 */

int sensorPin = 0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {

  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  

}

void loop() {

  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);          
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);                  

} @]

to:
June 25, 2009, at 11:55 PM by Tom Igoe -
Changed lines 11-14 from:

Circuit

to:

Circuit

An analog input connected to analog input pin 0.

click the image to enlarge

Schematic

click the image to enlarge

June 17, 2009, at 11:25 PM by Tom Igoe -
Changed lines 19-25 from:
 * AnalogInput
 * by DojoDave <http://www.0j0.org>
 *
 * Turns on and off a light emitting diode(LED) connected to digital  
 * pin 13. The amount of time the LED will be on and off depends on
 * the value obtained by analogRead(). In the easiest case we connect
 * a potentiometer to analog pin 2.
to:
  Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and
 turning on and off a light emitting diode(LED)  connected to digital pin 13. 
 The amount of time the LED will be on and off depends on
 the value obtained by analogRead(). 

 The circuit:
 * Potentiometer attached to analog input 0
 * center pin of the potentiometer to the analog pin
 * one side pin (either one) to ground
 * the other side pin to +5V
 * LED anode (long leg) attached to digital output 13
 * LED cathode (short leg) attached to ground

 * Note: because most Arduinos have a built-in LED attached 
 to pin 13 on the board, the LED is optional.

 Created by David Cuartielles
 Modified 16 Jun 2009
 By Tom Igoe

 http://arduino.cc/en/Tutorial/AnalogInput
Changed lines 45-48 from:

int potPin = 2; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int val = 0; // variable to store the value coming from the sensor

to:

int sensorPin = 0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor

Changed lines 50-51 from:
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
to:
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);  
Changed lines 55-59 from:
  val = analogRead(potPin);    // read the value from the sensor
  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(val);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  delay(val);                  // stop the program for some time
to:
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);          
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);                  
March 25, 2007, at 09:49 AM by David A. Mellis -
Added lines 1-43:

Examples > Analog I/O

Analog Input

A potentiometer is a simple knob that provides a variable resistance, which we can read into the Arduino board as an analog value. In this example, that value controls the rate at which an LED blinks.

We connect three wires to the Arduino board. The first goes to ground from one of the outer pins of the potentiometer. The second goes from 5 volts to the other outer pin of the potentiometer. The third goes from analog input 2 to the middle pin of the potentiometer.

By turning the shaft of the potentiometer, we change the amount of resistence on either side of the wiper which is connected to the center pin of the potentiometer. This changes the relative "closeness" of that pin to 5 volts and ground, giving us a different analog input. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and we read 0. When the shaft is turned all the way in the other direction, there are 5 volts going to the pin and we read 1023. In between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.

Circuit

Code

/*
 * AnalogInput
 * by DojoDave <http://www.0j0.org>
 *
 * Turns on and off a light emitting diode(LED) connected to digital  
 * pin 13. The amount of time the LED will be on and off depends on
 * the value obtained by analogRead(). In the easiest case we connect
 * a potentiometer to analog pin 2.
 */

int potPin = 2;    // select the input pin for the potentiometer
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor

void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
  val = analogRead(potPin);    // read the value from the sensor
  digitalWrite(ledPin, HIGH);  // turn the ledPin on
  delay(val);                  // stop the program for some time
  digitalWrite(ledPin, LOW);   // turn the ledPin off
  delay(val);                  // stop the program for some time
}

Share