Example code for an arduino.
The code uses the button de-bouncing library "Bounce" found here Link
Open the provided 'timer-less gate sensor example.config' in the configuration menu to load the correct gate codes.
#include <Bounce2.h>
#define LANE1_GATE1 2
#define LANE1_GATE2 3
#define LANE1_GATE3 4
#define LED_PIN 13
// Instantiate a Bounce object
Bounce debouncer1 = Bounce();
Bounce debouncer2 = Bounce();
Bounce debouncer3 = Bounce();
void setup() {
// Setup the buttons
pinMode(LANE1_GATE1,INPUT);
pinMode(LANE1_GATE2,INPUT);
pinMode(LANE1_GATE3,INPUT);
// Activate internal pull-up
digitalWrite(LANE1_GATE1,HIGH);
digitalWrite(LANE1_GATE2,HIGH);
digitalWrite(LANE1_GATE3,HIGH);
// After setting up the button, setup debouncers
debouncer1.attach(LANE1_GATE1);
debouncer1.interval(5);
debouncer2.attach(LANE1_GATE2);
debouncer2.interval(5);
debouncer3.attach(LANE1_GATE3);
debouncer3.interval(5);
//Setup Serial
Serial.begin(38400);
}
void loop() {
if(debouncer1.update()){
if (debouncer1.read()){
Serial.write("AZ");
}
}
if(debouncer2.update()){
if (debouncer2.read()){
Serial.write("AX");
}
}
if(debouncer3.update()){
if (debouncer3.read()){
Serial.write("AC");
}
}
}