Project using software serial, not ouputing info on serial monitor

HI everybody, I am trying to make mi ID12 RFID reader work. (it works, I conected it directly to my serial and it has outputted information).

I wanted to do something interfacing with arduino, I followed the playground example, and I didnt get any output from it.

After reading some pages I modified this way (basically I used two serials definition one for id 12 and one for communication and debugging)

// RFID reader ID-12 for Arduino
// Based on code by BARRAGAN http://people.interaction-ivrea.it/h.barragan
// and code from HC Gilje - RFID id-12 tagreader | Conversations with spaces
// Modified for Arudino by djmatic
// Modified for ID-12 and checksum by Martijn The - http://www.martijnthe.nl/
//
// Use the drawings from HC Gilje to wire up the ID-12.
// Remark: disconnect the rx serial wire to the ID-12 when uploading the sketch
#include <SoftwareSerial.h>
// The RFID module's TX pin needs to be connected to the Arduino.

#define rxPin 4
#define txPin 5

// Create a software serial object for the connection to the RFID module
SoftwareSerial rfid = SoftwareSerial( rxPin, txPin );

void setup() {
Serial.begin(9600); // Serial port for connection to host
rfid.begin(9600); // Serial port for connection to RFID module

Serial.println("RFID Reader Initialized");
}

void loop () {
byte i = 0;
byte val = 0;
byte checksum = 0;
byte bytesRead = 0;
byte tempByte = 0;
byte tagBytes[6]; // "Unique" tags are only 5 bytes but we need an extra byte for the checksum
char tagValue[10];

// Read from the RFID module. Because this connection uses SoftwareSerial
// there is no equivalent to the Serial.available() function, so at this
// point the program blocks while waiting for a value from the module
if((val = rfid.read()) == 2) { // Check for header
bytesRead = 0;
while (bytesRead < 12) { // Read 10 digit code + 2 digit checksum
val = rfid.read();

// Append the first 10 bytes (0 to 9) to the raw tag value
if (bytesRead < 10)
{
tagValue[bytesRead] = val;
}

// Check if this is a header or stop byte before the 10 digit reading is complete
if((val == 0x0D)||(val == 0x0A)||(val == 0x03)||(val == 0x02)) {
break; // Stop reading
}

// Ascii/Hex conversion:
if ((val >= '0') && (val <= '9')) {
val = val - '0';
}
else if ((val >= 'A') && (val <= 'F')) {
val = 10 + val - 'A';
}

// Every two hex-digits, add a byte to the code:
if (bytesRead & 1 == 1) {
// Make space for this hex-digit by shifting the previous digit 4 bits to the left
tagBytes[bytesRead >> 1] = (val | (tempByte << 4));

if (bytesRead >> 1 != 5) { // If we're at the checksum byte,
checksum ^= tagBytes[bytesRead >> 1]; // Calculate the checksum... (XOR)
};
} else {
tempByte = val; // Store the first hex digit first
};

bytesRead++; // Ready to read next digit
}

// Send the result to the host connected via USB
if (bytesRead == 12) { // 12 digit read is complete
tagValue[10] = '\0'; // Null-terminate the string

Serial.print("Tag read: ");
for (i=0; i<5; i++) {
// Add a leading 0 to pad out values below 16
if (tagBytes < 16) {

  • Serial.print("0");*
  • }*
    _ Serial.print(tagBytes*, HEX);_
    _
    }_
    _
    Serial.println();_
    _
    Serial.print("Checksum: ");_
    _
    Serial.print(tagBytes[5], HEX);_
    _
    Serial.println(tagBytes[5] == checksum ? " -- passed." : " -- error.");_
    _
    // Show the raw tag value*_
    * Serial.print("VALUE: ");*
    * Serial.println(tagValue);*

* Serial.println(); // Blank separator line in output*
* }*
* bytesRead = 0;*
* }*
}
[/quote]
I still cant read any tags... I get no output on my serial monitor.
(I have tried it in: Mac os X 10.6.7, Linux and Arduino Uno and Pro Mini)
Any information or aid to debug would be appreciated.

f((val = rfid.read()) == 2) {        // Check for header
    bytesRead = 0;
    while (bytesRead < 12) {            // Read 10 digit code + 2 digit checksum
      val = rfid.read();

How does that work?

AWOL:

f((val = rfid.read()) == 2) {        // Check for header

bytesRead = 0;
    while (bytesRead < 12) {            // Read 10 digit code + 2 digit checksum
      val = rfid.read();



How does that work?

AWOL, Thanks for replying, but I didnt understand the question, I just trying to make this example to work Arduino Playground - HomePage

But your code doesn't look anything like the example.

My question was intended to make you think how checking to see that you have exactly two characters available, and then going ahead and reading all twelve of them was going to work.

AWOL:
But your code doesn't look anything like the example.

My question was intended to make you think how checking to see that you have exactly two characters available, and then going ahead and reading all twelve of them was going to work.

The original example does not work, displaying the same problem (no output), after reading there was a suggestion of using two serial instances one for debug, one for id12.

I am puzzled why the serial doesnt work.

Just as a FYI: This is the wiring used on the ID12, standard:

http://www.wulfden.org/TheShoppe/freeduino/ID12_schem.jpg