Ест вопрос нужен ответ ))

Fearles8383
Offline
Зарегистрирован: 14.05.2015
код выводит при считывание номер карты в монитор порта Теперь вопрос как сделать что на определенную карту с номером загорался светодиод ??
volatile long reader1 = 0;

volatile int reader1Count = 0;

void reader1One(void) {

         reader1Count++;

         reader1 = reader1 << 1;

         reader1 |= 1;

}

void reader1Zero(void) {

         reader1Count++;

         reader1 = reader1 << 1;

}

void setup()

{

         Serial.begin(9600);

         // Attach pin change interrupt service routines from the Wiegand RFID readers

         attachInterrupt(0, reader1Zero, RISING);//DATA0 to pin 2

         attachInterrupt(1, reader1One, RISING); //DATA1 to pin 3

         delay(10);

         // the interrupt in the Atmel processor misses out the first negitave pulse as the inputs are already high,

         // so this gives a pulse to the reader input line to get the interrupts working properly.

         // Then clear out the reader variables.

         // The readers are open collector sitting normally at a one so this is OK

         for(int i = 2; i<4; i++){

                 pinMode(i, OUTPUT);

                 digitalWrite(i, HIGH); // enable internal pull up causing a one

                 digitalWrite(i, LOW); // disable internal pull up causing zero and thus an interrupt

                 pinMode(i, INPUT);

                 digitalWrite(i, HIGH); // enable internal pull up

         }

         delay(10);

         // put the reader input variables to zero

         reader1 = 0;

         reader1Count = 0;

}

void loop() {

         if(reader1Count >=26){

                 int serialNumber=(reader1 >> 1) & 0x3fff;

                 int siteCode= (reader1 >> 17) & 0x3ff;

                 Serial.print(" Reader 1:");

                 Serial.print(reader1,HEX);

                 Serial.print(" ");

                 Serial.print("Reader 1 converted to DEC:");

                 Serial.print(reader1& 0xfffffff);

                 Serial.print(" ");

                 Serial.print("siteCode:");

                 Serial.print(siteCode);

                 Serial.print(" ");

                 Serial.print("serial number:");

                 Serial.println(serialNumber);

                 reader1 = 0;

                 reader1Count = 0;

         }

}

 

maksim
Offline
Зарегистрирован: 12.02.2012
Fearles8383
Offline
Зарегистрирован: 14.05.2015

а можно по поджробней а то я начинающий 

Puhlyaviy
Puhlyaviy аватар
Offline
Зарегистрирован: 22.05.2013

Гыыы макс попал. Теперь обьясни как кликнуть на ссылку.

SunX
SunX аватар
Offline
Зарегистрирован: 04.10.2014