Semafor (3LED-uri, 3 rezistente 470Ohm)


void setup(){
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
}
 
void loop(){
  digitalWrite(13, HIGH);
  delay(800);
  digitalWrite(13, LOW);
  delay(50);
  digitalWrite(12,HIGH);
  delay(800);
  digitalWrite(12,LOW);
  delay(50);
  digitalWrite(11,HIGH);
  delay(800);
  digitalWrite(11,LOW);
  delay(50);
}

Utilizarea procedurilor


void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
}
void loop()
{
flash(13, 100);
flash(12, 100);
}

void flash(int pin, int durata)
{
digitalWrite(pin, HIGH);
delay(durata);
digitalWrite(pin, LOW);
delay(durata);
}

Utilizare vector(array) si proceduri

int durataa[]={200, 200, 200, 500, 500, 500, 200, 200, 200};

void setup()
{
pinMode(13, OUTPUT);
}

void loop()
{
for (int i=0; i<9; i++)
{
flash(13, durataa[i]);
}
delay(1000);
}

void flash(int pin, int durata)
{
digitalWrite(pin, HIGH);
delay(durata);
digitalWrite(pin, LOW);
delay(durata);
}