Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Zadaća za Primjenu Računala u Industriji - Arduino Semafori
- * Napisao: Tin Marković // Datum predavanja: 14.5.2015.
- */
- void wait(){ // Funkcija za čekanje dok se tipkalo ne upali i ugasi
- while(digitalRead(2) != HIGH){
- delay(10);
- }
- while(digitalRead(2) == HIGH){
- delay(10);
- }
- }
- void setup(){ // Postavljanje ulaza i izlaza
- pinMode ( 2, INPUT);
- for(int i=8; i<13; i++) pinMode ( i, OUTPUT);
- }
- void loop() { // Glavni kod koji se okreće
- wait(); // Stanje 1: Pali crveno za pješake i auta
- digitalWrite ( 11, LOW);
- digitalWrite ( 8, HIGH);
- digitalWrite ( 10, HIGH);
- wait(); // Stanje 2: Ugasi crveno, upali zeleno (pješaci)
- digitalWrite ( 8, LOW);
- digitalWrite ( 9, HIGH);
- wait(); // I tako dalje, nakon svake pauze gasimo ona svjetla
- digitalWrite ( 9, LOW); // koja prestaju važiti, i palimo slijedeća
- digitalWrite ( 8, HIGH);
- digitalWrite ( 10, HIGH);
- wait();
- digitalWrite ( 11, HIGH);
- wait();
- digitalWrite ( 10, LOW);
- digitalWrite ( 11, LOW);
- digitalWrite ( 12, HIGH);
- wait();
- digitalWrite ( 12, LOW);
- digitalWrite ( 11, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement