ugge75 / Wiegand-Protocol-Library-for-Arduino-MEGA-2560

Wiegand Library for Arduino MEGA 2560
20 stars 10 forks source link

2 Gates #10

Open PabloGin opened 4 years ago

PabloGin commented 4 years ago

Hi. I need to control only 2 gates. Is possible to use this library on Atmega328 for only 2 gates? I don't found where is the explanation of the pin selection. I'm new with arduino. Thanks, Pablo

Spoja commented 4 years ago

@PabloGin Hello, i dont think you can't control 2 gates with Atmega328 because it only has one set of interrupt pins (I might be wrong here, haven't worked with arduino for a while, but i think that is why i switched to 2560). The pins are defined in WiegandMega2560.cpp, in function WIEGAND::begin ( lines 77 to 130), functions used to define pins are: pinMode (Ivariables used for pinMode are defined in WiegandMega2560.h) and attachInterupt. I think you could use the library with Atmega328 but only for one gate, and it would be gate C according to the pinout.

PabloGin commented 4 years ago

Thank you. What i don't understand is,328 have Pin Change Interrupt Request, why I can't use this.

Spoja commented 4 years ago

You can use it, but only for gate C. Because 328 doesnt have enough pins with interrupts. Only pins PCINT18/INT0/PD2/pin 4 (to this one you connect Wiegand DATA1) and PCINT19/INT1/PD3/pin 5 (to this one Wiegand DATA0) have interrupt, those are different names those 2 pins go by. That way it should work without changing anything, if it doesn't you might have to try to change pins in WiegandMega2560.cpp lines 118-121.

PabloGin commented 4 years ago

My question is whether the ability of the original micro to have interruption by change of state on some pins can be used instead of the fixed interruption in the ARDUINO code

Spoja commented 4 years ago

Original micro is Atmega328, the Atmel chip, which only has only one set of interrupt pins (2 external pins) as far as im aware of, it has nothing to do with Arduino at all.