   // Now a card is selected. The UID and SAK is in mfrc522.uid.
 
   // Dump UID
-    if((millis()-lastCardScan) > timeBetweenScans){
+    if(millis() - lastCardScan > timeBetweenScans){
       lastCardScan = millis();
       // Some user feedback
       BEEP(1);

}

char rfid_raw_transmit(uint16_t number){
  //uint16_t number;                    // 0001 0110 0100 0111
  uint16_t mask   = B11111111;          // 0000 0000 1111 1111
  uint8_t first_half   = number >> 8;   // >>>> >>>> 0001 0110
  uint8_t sencond_half = number & mask; // ____ ____ 0100 0111
  for (int i = 0; i < TRANSMISSION_REPEATS*TRANSMISSION_ATOM_SIZE; i = i+TRANSMISSION_ATOM_SIZE) {
    Serial.write(sencond_half);
    Serial.write(first_half);
    Serial.write(TRANSMISSION_SPACE);
  }
}

  return false;
}

/* Returns address of card - returns 0xFFFF if card is not found */
int16_t findCardOffset(const card_t c){
  uint16_t addr;
  uint16_t last_addr = EEPROM_SIZE - sizeof(card_t); // EEPROM size minus element size
  for(addr = 0; addr <= last_addr; addr += sizeof(card_t)){
    if(EEPROM_compareAnything(addr,c.uid)){ // If bytes at address match, ok!
      //Serial.println(addr);
      return addr;
    }
  }
  return 0xFFFF; // Error value
}

int16_t findFreeCardSpot(){
  card_credits_t credits = 0;
  uint16_t addr = sizeof(card_uid_t); // Offset pointer, so we are looking at the card.credits
  uint16_t last_addr = EEPROM_SIZE - sizeof(card_credits_t); // EEPROM size minus size of one element
  for(addr; addr <= last_addr; addr += sizeof(card_t)){
    if(EEPROM_compareAnything(addr, credits)){ // If bytes at address match, ok!
      //Serial.println(addr-sizeof(card_uid_t));
      return addr-sizeof(card_uid_t); // Offset pointer again, so it points to beginning of card_t
    }
  }
  return 0xFFFF; // Error value
}

int tone_ = 0;

void BEEP(uint8_t n){
  unsigned char delayms = 100;
  beepp(delayms);
  for(uint8_t i=1;i<n;i++){
    delay(delayms);
    beepp(delayms);
  }
}

void beepp(unsigned char delayms){
  analogWrite(speakerOutPin, 100);     // Almost any value can be used except 0 and 255
                           // experiment to get the best tone
  delay(delayms);          // wait for a delayms ms
  analogWrite(speakerOutPin, 0);       // 0 turns it off
}                         
