El segundo sketch: The LED with button

Sketch 'The LED with a button'

Sketch 'The LED with a button'

Descripción.

Este sketch incluye el uso de un sensor (botón de pulsación) y un actuador (LED) nos permite manipular el ambiente de acuerdo a lo percibido.

La tarjeta Arduino es capaz de notar que ha sido presionado el botón (debajo del dedo en la imagen) y esta responde encendiendo el LED.  De manera antagónica, cuando el botón es liberado, la tarjeta Arduino apaga el LED.

Implementación.

Hardware.

  • En el pin digital 13 se inserta nuevamente el LED.
  • El botón se inserta en la protoboard.
  • Una de las patas del botón va a Power-5v.
  • La otra pata va al pin 7 (entrada – lectura de datos).
  • Una resistencia une la segunda pata del botón con la tierra.

Software.

#define LED 13              // Digital PIN for the LED
#define BUTTON 7            // Digital PIN for the Button

void setup ()
{
  pinMode(LED, OUTPUT);      // LED pin is output: turn it on/off
  pinMode(BUTTON, INPUT);    // Button pin is input: read it
}

void loop()
{
  if (digitalRead(BUTTON) == HIGH)    // Button is pressed
    digitalWrite(LED, HIGH);          // Turn the LED on
  else                                // Button is NOT pressed
    digitalWrite(LED, LOW);           // Turn the LED off
}
VN:F [1.8.4_1055]
Rating: 0 (from 0 votes)

Artículos relacionados:

  1. Modificación del segundo sketch: The LED with button and state
  2. El tercer sketch: The LED with button and fade
  3. El cuarto sketch: The LED with fotoresistor
  4. Mi primer sketch con Arduino: The blinking LED
  5. Una primera mirada a Arduino

Category: Desarrollo de hardware, Desarrollo de software | Tags: , One comment »

One Response to “El segundo sketch: The LED with button”

  1. Modificación del segundo sketch: The LED with button and state | Jorge Iván Meza Martínez

    [...] sketch se encuentra completamente basado en el anterior al cual se le modifica su funcionalidad permitiendo manipular un estado para el LED, es decir, [...]


Leave a Reply



Back to top