hello,
i have program written text different message based on tag read. works out, except rfid scan 1 tag, , green light stays lit. way have found reset open serial monitor again. post code , insight appreciated.
thanks
i have program written text different message based on tag read. works out, except rfid scan 1 tag, , green light stays lit. way have found reset open serial monitor again. post code , insight appreciated.
thanks
code: [select]
#include <softwareserial.h>
softwareserial sim900(7,8);
char card[12] = {'7','2','0','0','7','7','5','2','4','9'};
char card2[12] = {'7','2','0','0','7','7','4','9','e','b'};
char code[12];
int bytesread = 0;
int rfidpin = 2; // rfid enable pin connected digital pin 2
int val=0;
void setup()
{
serial.begin(2400); // rfid reader sout pin connected serial rx pin @ 2400bps
pinmode(rfidpin,output); // set digital pin 2 output connect rfid /enable pin
digitalwrite(rfidpin, low); // activate rfid reader
sim900.begin(19200);
sim900power();
delay(10000);
}
void sim900power()
{digitalwrite(9,high);
delay(1000);
digitalwrite(9,low);
delay(3000);
}
void sendsms()
{
sim900.println("code great: ");
sim900.print("at+cmgf=1\r"); // @ command send sms message
delay(100);
sim900.println("at + cmgs = \"+xxxxxxxxxxx\""); // recipient's mobile number, in international format
delay(100);
sim900.println("hello"); // message send
delay(100);
sim900.println((char)26); // end @ command ^z, ascii code 26
delay(100);
sim900.println();
delay(5000); // give module time send sms
sim900power(); // turn off module
}
void sendsms2()
{
sim900.println("code good: ");
sim900.print("at+cmgf=1\r"); // @ command send sms message
delay(100);
sim900.println("at + cmgs = \"+xxxxxxxxxxx\""); // recipient's mobile number, in international format
delay(100);
sim900.println("howdy"); // message send
delay(100);
sim900.println((char)26); // end @ command ^z, ascii code 26
delay(100);
sim900.println();
delay(5000); // give module time send sms
sim900power(); // turn off module
}
void loop()
{
digitalwrite(rfidpin, low);
if(serial.available() > 0) // if data available reader
{
if((val = serial.read()) == 10) // check 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 10 digit reading
break; // stop reading
code[bytesread] = val; // add digit
bytesread++; // ready read next digit
}
}
if(bytesread >= 10) // if 10 digit read complete
{
digitalwrite(rfidpin, high); // de-activate rfid reader
if(strcmp(code, card) == 0)
{
serial.print("code accecpted: ");
serial.println(code);
sendsms();
{} while (1);
}
if(strcmp(code, card2) == 0)
{
serial.print("code alright: ");
serial.println(code);
sendsms2();
{} while (1);
}
else
{
serial.print(code);
serial.println(" not valid!");
}
}
bytesread = 0;
delay(500); // wait second
}
}
}
could post code using code tags.
i don't want have to:
download file,
store in folder correct name.
open arduino ide view file.
and delete file after viewing it.
i'd rather read on page.
i don't want have to:
download file,
store in folder correct name.
open arduino ide view file.
and delete file after viewing it.
i'd rather read on page.
Arduino Forum > Using Arduino > Project Guidance > RFID will only read tag once. Help.
arduino
Comments
Post a Comment