Go Down

Topic: Arduino UNO+ Wiegand + Softwareserial (Read 6 times) previous topic - next topic

acbruno

Hi,
I need help...
I set up an RFID reader using Arduino uno + RC522 which to swipe the card, search a db and receives a variable via SoftwareSerial to "talk" which relay trigger. Variable A, B, C
I am now added to the Wiegand readers (EM4100 WG26), but the system does not accept or receive the variable by Serial.Read (), I've tried include SoftwareSerial, but also does not recover the variable and therefore do not trigger the relay.
Does anyone have an idea how I can get this variable by SoftwareSerial?

I am sending the code without SoftwareSerial. The idea is to make the "char read" receive the string via serial.
Thank you !


-----------
#include <Wiegand.h>
WIEGAND wg;
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5);

int ledPin1 = 7;
int ledPin2 = 6;
int ledPin3 = 5;
int ledPin4 = 4;
char leitura;



void setup() {
  Serial.begin(9600);   // CONECTA A PORTA SERIAL E DIFINE A VELOCIDADE DE LEITURA
  mySerial.begin(9600);  // CONECTA A PORTA SERIAL E DIFINE A VELOCIDADE DE LEITURA
  pinMode(ledPin1, OUTPUT);  // DEFINE A PINAGEM REFERENTE A VARIAVEL COMO PINO DE SÁIDA
  pinMode(ledPin2, OUTPUT);  // DEFINE A PINAGEM REFERENTE A VARIAVEL COMO PINO DE SÁIDA
  pinMode(ledPin3, OUTPUT);  // DEFINE A PINAGEM REFERENTE A VARIAVEL COMO PINO DE SÁIDA
  pinMode(ledPin4, OUTPUT);  // DEFINE A PINAGEM REFERENTE A VARIAVEL COMO PINO DE SÁIDA
  wg.begin();
}

void loop () {
  // ENQUANTO A PORTA SERIAL3 ESTIVER DISPONÍVEL, FAZ LEITURA E ENVIA AS INFORMAÇÕES PARA O SISTEMA
 if(mySerial.available() > 0) {
    leitura = mySerial.read();
    Serial.print(leitura);   
  }

   
   
  // RECEBE DO SISTEMA A STRING 'a' E ACIONA O LED
 if(wg.available() > 0) {
    //char b = wg.getCode();
    char b = Serial.read();

     if(b == 'M'){
       digitalWrite(ledPin1, HIGH); 
       delay(1000);
       digitalWrite(ledPin1, LOW);
     }
     if(b == 'V'){
       digitalWrite(ledPin2, HIGH); 
       delay(1000);
       digitalWrite(ledPin2, LOW);
     } 
     if(b == 'E'){
       digitalWrite(ledPin3, HIGH); 
       delay(1000);
       digitalWrite(ledPin3, LOW);
     } 
     if(b == 'P'){
       digitalWrite(ledPin4, HIGH); 
       delay(1000);
       digitalWrite(ledPin4, LOW);
     }    }   
}

Go Up