pugliasos newlogoDEF

Orario della segreteria: tutti i martedì, dalle ore 17 alle 19, su appuntamento.


Semaforo a due direzioni html d159e4cc2416e881 

  

Il codice

 

#define rosso_O1 11

#define giallo_O1 12

#define verde_O1 13

#define rosso_O2 2

#define giallo_O2 3

#define verde_O2 4

#define rosso_V1 8

#define giallo_V1 9

#define verde_V1 10

#define rosso_V2 5

#define giallo_V2 6

#define verde_V2 7

 

void commuta_O(bool R, bool G, bool V) {

digitalWrite(rosso_O1, R);

digitalWrite(rosso_O2, R);

digitalWrite(giallo_O1, G);

digitalWrite(giallo_O2, G);

digitalWrite(verde_O2, V);

digitalWrite(verde_O1, V);

}

 

void commuta_V(bool R, bool G, bool V) {

digitalWrite(rosso_V1, R);

digitalWrite(rosso_V2, R);

digitalWrite(giallo_V1, G);

digitalWrite(giallo_V2, G);

digitalWrite(verde_V2, V);

digitalWrite(verde_V1, V);

}

 

void setup() {

for (int i = 2; i <= 13; i++) {

pinMode(i, OUTPUT);

}

for (int i = 2; i <= 6; i++) {

commuta_O(0,1,0);

commuta_V(0,1,0);

delay(1000);

commuta_O(0,0,0);

commuta_V(0,0,0);

delay(1000);

}

}

 

void loop() {

commuta_O(0,0,1);

commuta_V(1,0,0);

delay(5000);

commuta_O(0,1,0);

commuta_V(1,0,0);

delay(1000);

commuta_O(1,0,0);

commuta_V(0,0,1);

delay(5000);

commuta_O(1,0,0);

commuta_V(0,1,0);

delay(1000);

}

Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline