my code stock.com

Incorporación y uso de variables

Snippet options

Download: Download snippet as leccion-02.txt.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

/*============================================
                   Hola Mundo
  ============================================
Enciende un LED por un segundo y lo apaga por el mismo tiempo
Se incorpora el uso de variables: 'pinLed' y 'pausa' 

  ===========================================
   Declaración de Variables y tipo a utilizar
  ============================================*/

int pinLed = 13;            // Establece 'pinLed' como variable entera
                            // igual a 13
int pausa = 1000;           // Establece 'pausa' como variable entera
                            // con un valor inicial de 1s = 1000ms                               

/*============================================
     Bloque principal de configuración
  ============================================*/
  
void setup() {                 // Se ejecuta cada vez que el Arduino se inicia

  pinMode(pinLed, OUTPUT);     // Inicializa 'pinLed' como una salida
                               // La placa Arduino incluye un led en el pin 13
}

/*============================================
      Bloque principal de programa cíclica
  ============================================*/

void loop() {                  // Esta función se mantiene ejecutando
                               // cuando este energizado el Arduino
  digitalWrite(pinLed, HIGH);  // Enciende el LED
  delay(pausa);                // Temporiza un segundo (1s = 1000ms)
  digitalWrite(pinLed, LOW);   // Apaga el LED
  delay(pausa);                // Temporiza un segundo (1s = 1000ms)

}  

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.