#define STATE_OPEN_GATE 2 // STATE_OPEN_GATE : door is open. Keep the door open while receiving tram. Go to STATE_SCAN when not receiving tram after GO_TO_SCAN_STATE_DELAY
#define SCAN_TIME 2 // scan period in second
#define GO_TO_SCAN_STATE_DELAY 4 // if no trame was received during 4 sec, go to STATE_SCAN
#define DELAY_REJECT_TRAM 3 // if the last tram was received more than 3 seconds ago, the average RSSI is not computed and returns an average RSSI of -100
#define GO_TO_SCAN_STATE_DELAY 4 // if no trame was received during X sec, go to STATE_SCAN
#define DELAY_REJECT_TRAM 3 // if the last tram was received more than X seconds ago, the average RSSI is not computed and returns an average RSSI of -100
#define PULSE_DURATION 500 // pulse to open gate. duration in ms
#define DELAY_BETWEEN_PULSE 4 // to keep the gate open emit a pulse every X seconds
#define RSSI_THRESHOLD_OPEN_GATE -95 // if the average RSSI is above this threshold the gate can be open
// ***** definitions *****
...
...
@@ -31,192 +33,195 @@ struct RSSI { // table contening the RSSI and time of the last 2 trams. Used to
intval=-100;
time_ttime=0;
}tabRSSI[2];
time_ttPulseGate=0;
// ***** open gate *****
voidopenGate(){
Serial.println(" OPENING GATE");//DEBUG
digitalWrite(RELAY1,HIGH);//activate relay1 for 0.5 sec