Tuesday, November 25, 2014

Semaforo con arduino - demo per il simulatore di laboratorio

Questo video mostra come potrebbe essere comandato un simulatore di semaforo.
Per usare le tensioni (24V) di laboratorio occorre alimentare in modo alternativo e cambiare le resistenze.



ecco lo sketch:

void setup (){
pinMode(2,OUTPUT); //LED ROSSO1
pinMode(3,OUTPUT); //led GIALLO1
pinMode(4,OUTPUT); // LED VERDE1
pinMode(5,OUTPUT); //LED ROSSO2
pinMode(6,OUTPUT); //led GIALLO2
pinMode(7,OUTPUT); // LED VERDE2
}
void loop(){



  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH);
  delay(10000);
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  digitalWrite(5,LOW);
  digitalWrite(6,HIGH);
  digitalWrite(7,LOW);
  delay(3000);
  digitalWrite(2,LOW);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
  delay(10000);
  digitalWrite(2,LOW);
  digitalWrite(3,HIGH);
  digitalWrite(4,LOW);
  digitalWrite(5,HIGH);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
  delay(3000);
  }
Post a Comment