Hi,
yes thats what I meant.
The devices I use are two Freeduinos ATMega328, one Parallax RFID reader connected to the one with an RFlink transmitter (here: http://www.coolcomponents.co.uk/catalog/product_info.php?products_id=186)
and the second Freeduino is connected with the receiver. The transmitter runs on 8V for higher performance and the rest on 5V.
To mention. The RFID reads perfectly well without the Virtual Library stuff, and the transmitter transmits fine without the RFID reading. Thats why I think there is something going on with the Library. Do you think it is a path problem, since I reinstalled the Library (tried both the old and updated versions of the VW)
The code for the transmitter that used to work fine but now doesnt is this one:
TRANMITTER CODE:
#include <SoftwareSerial.h>
#include <VirtualWire.h>
#undef round
//-----------------------------------------------------------//FOR RF -> DH
int whichTag = 1; //the variable saying which tag was read
#define ledPin 13
//-----------------------------------------------------------//for rfid
#define rxPin 3 //connect with SOUT / TX in RFID at 2400bps
#define txPin 2 //conenct with enable pin
SoftwareSerial RFID = SoftwareSerial(rxPin,txPin);
byte rfidval = 0;
char code[10];
int bytesread = 0;
char tag1[] = {
'2', '3', '0', '0', '6', 'E', '7', '6', '6','4'};
char tag2[] = {
'2', '3', '0', '0', '6', 'E', '5', 'D', '7','F'};
char tag3[] = {
'2', '3', '0', '0', '6', 'F', '7', '7', '1','E'};
//-----------------------------------------------------------//setup
void setup() {
Serial.begin(9600); //NECESSARY
RFID.begin(2400);
pinMode(ledPin, OUTPUT);
pinMode(txPin, OUTPUT);
pinMode(rxPin, INPUT);
// RF LINK STUFF -> DH
vw_set_tx_pin(9);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
digitalWrite(txPin, LOW); // Activate the RFID reader
}
void loop(){
rfidval = RFID.read();
//-----------------------------------------------------//
if(rfidval == 10)
{
bytesread = 0;
while(bytesread<10)
{
rfidval = RFID.read();
if((rfidval == 10)||(rfidval == 13))
{
break;
}
code[bytesread] = rfidval;
bytesread++;
}
//-----------------------------------------------------------//start to compare tags with with code
if(bytesread == 10)
{ // if 10 digit read is complete
for(int i=0; i<10;i++){
//Serial.print(code[i]);
if (code[7]==tag1[7] && code[8]==tag1[8] && code[9]==tag1[9]) { // 1
flickrLED();
whichTag = 1;
Serial.println("1");
}
if (code[7]==tag2[7] && code[8]==tag2[8] && code[9]==tag2[9]) { // 2
flickrLED();
whichTag = 2;
Serial.println("2");
}
if (code[7]==tag3[7] && code[8]==tag3[8] && code[9]==tag3[9]) { // 3
flickrLED();
whichTag = 3;
Serial.println("3");
}
}
}
}
handleRF();
}
void flickrLED() {
digitalWrite(ledPin, HIGH);
delay(20);
digitalWrite(ledPin, LOW);
delay(20);
}
void handleRF()
{
if (whichTag == 1) {
const char *msg = "s21";
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
}
else if (whichTag == 2) {
const char *msg = "s22";
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
}
else if (whichTag == 3) {
const char *msg = "s23";
digitalWrite(13, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, false);
}
}
and the RECEIVER CODE:
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
// Initialise the IO and ISR
// vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_set_rx_pin(8); //otherwise pin is by default 11
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i], BYTE);
}
Serial.println("");
digitalWrite(13, false);
}
}
What do think?...
Thanks,
A