Operácie

Acrob003

Zo stránky SensorWiki

Verzia tlače už nie je podporovaná a môže obsahovať chyby pri vykresľovaní. Prosím aktualizujte záložky vo svojom prehliadači a použite predvolenú funkciu pre tlač v prehliadači.

LED blink


Your board contains one user programmable LED diode (see schematic). Let's try to controll it using the followng programm:

#define LED_Yellow 13                // select the pin for LED

void setup()
{
 pinMode(LED_Yellow, OUTPUT );       // this pin is an OUTPUT
}

void loop() // endless loop
{
 digitalWrite(LED_Yellow, HIGH);    // make it visible
 delay(1000);                       // wait 1000 ms = 1s
 digitalWrite(LED_Yellow, LOW);     // turn off
 delay(1000);                       // wait again
}

How it works

It is necessary to determine whether the certain pin will be configured as an INPUT or OUTPUT one. This is done in Setup section using the command

Your turn

Connect Your own LED on the experimental breadboard. Connect the LED to the pin D2, it will be assigned with number 2 in Your program digitalWrite(2,HIGH).

Change the program to blink with both LEDs - Your and the onboard. Can You program them tu blink mutually like on the railway crosses?


< Previous | Home | Next >