   // different seed numbers each time the sketch runs.
   // randomSeed() will then shuffle the random function.
   randomSeed(analogRead(0));
+  // Set mode in all inputs as pullup
+  for (int i = 0; i < DIFFERENT_VALUES; i++) {
+    pinMode(i + FIRST_INPUT, INPUT_PULLUP);
+  }
+  // Set mode in all outputs
+  for (int i = 0; i < DIFFERENT_VALUES; i++) {
+    pinMode(i + FIRST_OUTPUT, OUTPUT);
+  }
   // Will show input/output state
   pinMode(13, OUTPUT);
+  // Initialize serial
+  Serial.begin(9600);
 }
 
 void loop() {

const int DIFFERENT_VALUES = 4;
const int MAX_LENGTH = 20;
const int SHOW_DELAY = 1000;
const int BLINK_DELAY = 300;
const int DEBOUNCE_DELAY = 50;

int sequence[MAX_LENGTH];
int currentLength = 0;

// Set every pin to specified mode
void setMode(int mode) {
  for (int i = 0; i < DIFFERENT_VALUES; i++) {
    pinMode(i, mode);
  }
  // To show current mode
  if (mode == OUTPUT) {
    digitalWrite(13, LOW);
  } else {
    digitalWrite(13, HIGH);
  }
}

// Increase the random sequence in one element
void newElement() {

  int pushedElement = -1;
  while (pushedElement == -1) {
    for (int i = 0; i < DIFFERENT_VALUES; i++) {
      // Value to check must be LOW, because input is pull up
      if (digitalRead(i + FIRST_INPUT) ==  LOW) {
        // Waits some milliseconds to prevent bouncing
        delay(DEBOUNCE_DELAY);
        // Pusher is still pushed
        if (digitalRead(i + FIRST_INPUT) ==  LOW) {
          pushedElement = i;
          waitForUnpush();
          // Doesn't read other inputs
          break;
        }
      }
    }
    delay(READ_WAITING_DELAY);
  }
  return pushedElement;
}

void blinkCorrectElement(int element) {
  while (true) {
    digitalWrite(element + FIRST_OUTPUT, HIGH);
    delay(BLINK_DELAY);
    digitalWrite(element + FIRST_OUTPUT, LOW);
    delay(BLINK_DELAY);
  }
}

void readSequence() {
  digitalWrite(13, HIGH);
  for (int i = 0; i < currentLength; i++) {
    int pushed = readFirstPushed();
    if (sequence[i] != pushed) {
      // Wrong element, game over
      Serial.println("Game over");
      Serial.print("Sequence was ");
      Serial.print(sequence[i]);
