Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.0 kB
1
Indexable
Never
// C++ code
//


//Pinovi 2,3,4,5,6 diode koje idu lijevo desno
//Pin 7 gumb
//Pin 8 cilj dioda


int dly = 250;

int aktivnaDioda = 0;

int gumbStatus = 0;

void setup()
{
  Serial.begin(9600);
  for(int i = 2 ; i <= 6 ; i++){
      pinMode(i, OUTPUT);
  }
  pinMode(8,OUTPUT);
  pinMode(7,INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(7), test, FALLING);
 
}

void loop()
{

  
  for(int i = 2 ; i <= 6 ; i++){
      digitalWrite(i, HIGH);
      aktivnaDioda = i;
      delay(dly);
      digitalWrite(i, LOW);
      digitalWrite(i+1, HIGH);
      aktivnaDioda = i+1;
  }
    
   for(int i = 6 ; i >= 2 ; i--){
      digitalWrite(i, HIGH);
      aktivnaDioda = i;
      delay(dly);
      digitalWrite(i, LOW);
      digitalWrite(i-1, HIGH);
      aktivnaDioda = i-1;
  }
  
}

void test(){
  digitalWrite(8, HIGH);
  if (aktivnaDioda == 4){
    Serial.print("LEVEL UP!");
    dly = dly + 80;
  }else{
  	digitalWrite(8, HIGH);
    delay(150);
    digitalWrite(8, HIGH);
    delay(150);
    digitalWrite(8, HIGH);
    delay(150);
  }
}