#include <Arduino.h>

// Define pins used for wires and LEDs.
// C1 - Core number | CW - Marking the correct wire | WW - Marking the wrong wire.
const int C1CW = 13;
const int C1WW = 12;
const int C1Led = 2;

const int C2CW = 11;
const int C2WW = 10;
const int C2Led = 3;

const int C3CW = 9;
const int C3WW = 8;
const int C3Led = 4;

const int C4CW = 7;
const int C4WW = 6;
const int C4Led = 5;

// Define pins for activation switch and buzzer.
const int buzzer = A1;
const int activator = A0;

// Define initial countdown time.
const int initialTime = 240;

// Define speedup for cutting the wrong wire.
const float speedupFactor = 1.5;

// Initialize countdown time and wire states.
int countdownTime = initialTime;

int C1CWState = 0;
int C1WWState = 0;

int C2CWState = 0;
int C2WWState = 0;

int C3CWState = 0;
int C3WWState = 0;

int C4CWState = 0;
int C4WWState = 0;

void setup()
{ // put your setup code here, to run once:
  
  // Set wire pins as input and LED pins as output.
  pinMode(C1CW, INPUT);
  pinMode(C1WW, INPUT);
  pinMode(C1Led, OUTPUT);
  
  pinMode(C2CW, INPUT);
  pinMode(C2WW, INPUT);
  pinMode(C2Led, OUTPUT);
  
  pinMode(C3CW, INPUT);
  pinMode(C3WW, INPUT);
  pinMode(C3Led, OUTPUT);
  
  pinMode(C4CW, INPUT);
  pinMode(C4WW, INPUT);
  pinMode(C4Led, OUTPUT);
  
  // Set initial LED state to off.
  digitalWrite(C1Led, LOW);
  digitalWrite(C2Led, LOW);
  digitalWrite(C3Led, LOW);
  digitalWrite(C4Led, LOW);
  
  // Initialize serial communication for debugging.
  Serial.begin(9600);
}

void loop()
{ // put your main code here, to run repeatedly:
  
  // delay(10); // Delay a little bit to improve simulation performance
  
  // Read the wire states.
  C1CWState = digitalRead(C1CW);
  C1WWState = digitalRead(C1WW);
  
  C2CWState = digitalRead(C2CW);
  C2WWState = digitalRead(C2WW);
  
  C3CWState = digitalRead(C3CW);
  C3WWState = digitalRead(C3WW);
  
  C4CWState = digitalRead(C4CW);
  C4WWState = digitalRead(C4WW);
  
  // Check if correct wire was cut.
  if (C1CW, C2CW, C3CW, C4CW == HIGH)
  {
    Serial.println("Ispravna žica prerezana - Prva jezgra deaktivirana!");
    digitalWrite(C1Led, HIGH); // Turn on the LED
    while (true) // Wait forever
    {
      /* code */
    }
  }
  
  // Check if wrong wire was cut.
  if (C1WW, C2WW, C3WW, C4WW == HIGH)
  {
    Serial.println("Kriva žica prerezana - Odbrojavanje ubrzano!");
    countdownTime = countdownTime / speedupFactor;
  }
  
  // Decrement the countdown timer and check if it's expired.
  countdownTime--;
  if (countdownTime <=0)
  {
    Serial.println("Odbrojavanje je isteklo - Bomba je eksplodirala!");
    // Turn on the LEDs
    digitalWrite(C1Led, HIGH);
    digitalWrite(C2Led, HIGH);
    digitalWrite(C3Led, HIGH);
    digitalWrite(C4Led, HIGH);
    while (true) // Wait forever
    {
      /* code */
    } 
  }
  
  // Delay for 1 second before checking the wire states again.
  delay(1000);
  
}

$abcdeabcde151015202530fghijfghij
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
btn3:1.l
btn3:2.l
btn3:1.r
btn3:2.r
btn4:1.l
btn4:2.l
btn4:1.r
btn4:2.r
btn5:1.l
btn5:2.l
btn5:1.r
btn5:2.r
btn6:1.l
btn6:2.l
btn6:1.r
btn6:2.r
btn7:1.l
btn7:2.l
btn7:1.r
btn7:2.r
btn8:1.l
btn8:2.l
btn8:1.r
btn8:2.r
btn9:1.l
btn9:2.l
btn9:1.r
btn9:2.r
btn10:1.l
btn10:2.l
btn10:1.r
btn10:2.r
btn11:1.l
btn11:2.l
btn11:1.r
btn11:2.r
btn12:1.l
btn12:2.l
btn12:1.r
btn12:2.r
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2
bz1:1
bz1:2
sw1:1
sw1:2
sw1:3