require 'raspi/Diode.php';
//scan card
$buzzer = new Buzzer();
$buzzer->buzzStop();
$diode = new Diode();
$diode->off();
while (true) {
    echo "Wait for card...\n";
    do {
        $uid = getNfcUID();
    } while ($uid == NULL);
    echo "Insert {$uid} card\n";
    $newCard = new stdClass();
    $newCard->cardid = $uid;
    addCard($newCard);
    $buzzer->buzzStart();
    $diode->on();
    sleep(1);
    $buzzer->buzzStop();
    echo "Remember take card back...\n";
    while ($uid != NULL && getNfcUID() == $uid) {
    }
    $diode->off();
}
function getNfcUID()
{
    sleep(1);
    try {
        $match = [];
        $lsnfc = shell_exec('sudo lsnfc');
        if (preg_match('/UID\\=[a-zA-Z0-9]*/', $lsnfc, $match)) {