2891
Comentario:
|
1881
|
Los textos eliminados se marcan así. | Los textos añadidos se marcan así. |
Línea 12: | Línea 12: |
* 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 * 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 |
/ * AnalogInput<<BR>> * by DojoDave <http://www.0j0.org><<BR>> * http://www.arduino.cc/en/Tutorial/AnalogInput<<BR>> */<<BR>> int potPin = 2; // select the input pin for the potentiometer<<BR>> int ledPin = 13; // select the pin for the LED<<BR>> int val = 0; // variable to store the value coming from the sensor<<BR>> <<BR>> void setup() {<<BR>> pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT<<BR>> }<<BR>> <<BR>> void loop() {<<BR>> val = analogRead(potPin); // read the value from the sensor<<BR>> digitalWrite(ledPin, HIGH); // turn the ledPin on<<BR>> delay(val); // stop the program for some time<<BR>> digitalWrite(ledPin, LOW); // turn the ledPin off<<BR>> delay(val); // stop the program for some time<<BR>> }<<BR>> |
Línea 19: | Línea 32: |
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 21: | Línea 33: |
void setup() { | |
Línea 23: | Línea 34: |
. pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT | <<BR>><<BR>> |
Línea 25: | Línea 36: |
} 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 } |
A este |
Curso Sensibilización Hardware Libre (Unidad 002)
Tabla de Contenidos
002/02 Actividad 002
/ * 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
}
A este