Cintillo Institucional
Diferencias entre las revisiones 3 y 4
Versión 3 con fecha 2009-04-24 12:02:03
Tamaño: 2000
Comentario:
Versión 4 con fecha 2009-04-24 12:03:26
Tamaño: 2922
Comentario:
Los textos eliminados se marcan así. Los textos añadidos se marcan así.
Línea 12: Línea 12:

Línea 15: Línea 13:
 * AnalogInput * 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.
*
* http://www.arduino.cc/en/Tutorial/AnalogInput
*/
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
} * AnalogInput
Línea 17: Línea 37:
 *
* Turns on and off a light emitting diode(LED) connected to digital  
 *  * Turns on and off a light emitting diode(LED) connected to digital
Línea 22: Línea 41:
 *
* http://www.arduino.cc/en/Tutorial/AnalogInput
 */
 *  * http://www.arduino.cc/en/Tutorial/AnalogInput
Línea 26: Línea 43:
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
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
Línea 31: Línea 46:
  pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
. pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Línea 35: Línea 52:
  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

 .
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
Línea 41: Línea 56:

wiki comunidad

Proyecto Hardware Libre Cenditel

Página Cenditel

wiki Cenditel

Plataforma de Desarrollo Colaborativo

Curso Sensibilización Hardware Libre (Unidad 002)

logohl.png logohl.png logohl.png

002/02 Actividad 002

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

}

hlpd/curso_arduino/uni00202 (última edición 2011-07-15 16:43:51 efectuada por _desactivada_csoto)