Ribeirão Preto - SP
Offline
Jr. Member
Karma: 0
Posts: 61
|
 |
« Reply #6 on: May 28, 2011, 03:29:08 pm » |
Pessoal, estou trabalhando no meu programa e estou usando o seguinte,,,
#include <SoftwareSerial.h> #define rxPin 0 #define txPin 1
#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Inicializa a biblioteca de lcd com os pinos referentes
#define TAG_LEN 12 char tag[12] = {'3', '6', '0', '0', '7', '8', '9', '9', '8', '7'}; //tag 1 char tag2[12] = {'3', '6', '0', '0', '7', '8', '9', 'B', 'B', '5'}; //tag 2 char code[12]; int bytesread = 0; //Connections to be made: int ledPin = 13; // Connect LED to pin 13 int val=0; void setup() { lcd.begin(16, 2); // set up the LCD's number of rows and columns lcd.print("Inicializando..."); delay (1000);
Serial.begin(9600); Serial.begin(9600); pinMode (rxPin, INPUT); pinMode (txPin, OUTPUT); pinMode(ledPin,OUTPUT); // Set ledPin to output }
void loop() { digitalWrite(ledPin,LOW); //LED off lcd.clear(); //Clears LCD lcd.setCursor(0, 0); lcd.print(" Aproxime"); lcd.setCursor(0, 1); lcd.print(" O Cartao"); if(Serial.available() > 0) { // if data available from reader if((val = Serial.read()) == 10) { // check for header bytesread = 0; while(bytesread<10) { // read 10 digit code if( Serial.available() > 0) { val = Serial.read(); if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading break; // stop reading } code[bytesread] = val; // add the digit bytesread++; // ready to read next digit
} }
if(bytesread >= 10) { // if 10 digit read is complete if(strcmp(code, tag) == 0) { lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Accesso Liberado"); lcd.setCursor(0, 1); lcd.println(code); delay (1500); lcd.setCursor(0, 1); lcd.print("Rafael "); digitalWrite(ledPin,HIGH); Serial.print("Tag matches: "); Serial.println(code); digitalWrite(ledPin,HIGH); delay(2000); // wait for a second or two return; //Go to the top, skip the bottom } else { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Accesso Negado"); lcd.setCursor(0, 1); lcd.println(code); Serial.print(code); Serial.println(" does not match"); }
} bytesread = 0; delay(2000); // wait for a second digitalWrite(ledPin,LOW); } } }
O lcd esta funcionando perfeitamente, mas o programa parece não estar recebendo informação da placa rfid, o que pode estar errado? estou usando um rfid 125khz do seeedstudio.com ligado na porta serial do arduino e usando o modo UART,,
Se alguem puder ajudar
|