Arduino RX / TX

hey guys i was trying to connect a gps to my arduino through the digitals pins in instead of the RX TX pins.. can i do that and will work at the same way?

hey guys i was trying to connect a gps to my arduino through the digitals pins in instead of the RX TX pins.. can i do that and will work at the same way?

Well the rx/tx pins are digital pins also, they just happen to be the two pins internally connected to the serial hardware inside the processor. You are free to utilize software serial libary to perform serial communications on other free digital pins.

http://arduino.cc/en/Reference/SoftwareSerial

Lefty

On the same note, what does TX refer to and what does RX refer to so I can get my LEDs the right color. :D

TX = Texas and it would be the color of sagebrush, or cattle, or maybe black for crude oil? RX = Prescription. They usually come in those orange plastic bottles.

Some people think that TX = transmit and RX = receive, and the LEDs are both green. But how boring is that?

Too funny....What colors....Hmm..Green and Yellow maybe.

Well the rx/tx pins are digital pins also, they just happen to be the two pins internally connected to the serial hardware inside the processor. You are free to utilize software serial libary to perform serial communications on other free digital pins.

http://arduino.cc/en/Reference/SoftwareSerial

Lefty

so i can easily read the gps with that

so i can easily read the gps with that

I'm don't know if you easily can, others have, I haven't tried yet. ;)

Lefty

yes but it give me a error

#include <SoftwareSerial.h>
#include <string.h>
#include <ctype.h>

#define rxPin 2
#define txPin 3
#define ledPin = 13
int byteGPS=-1;
char linea[300] = “”;
char comandoGPR[7] = “$GPRMC”;
int cont=0;
int bien=0;
int conta=0;
int indices[13];
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
byte pinState = 0

void setup() {
pinMode(ledPin, OUTPUT); // Initialize LED pin
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(960);
for (int i=0;i<300;i++){ // Initialize a buffer for received data
linea*=’ ';*

  • } *
    }
    void loop() {
  • digitalWrite(ledPin, HIGH);*
  • byteGPS=mySerial.read(); // Read a byte of the serial port*
  • if (byteGPS == -1) { // See if the port is empty yet*
  • delay(100);*
  • } else {*
  • linea[conta]=byteGPS; // If there is serial port data, it is put in the buffer*
  • conta++; *
  • mySerial.print(byteGPS, BYTE);*
  • if (byteGPS==13){ // If the received byte is = to 13, end of transmission*
  • digitalWrite(ledPin, LOW);*
  • cont=0;*
  • bien=0;*
  • for (int i=1;i<7;i++){ // Verifies if the received command starts with $GPR*
    _ if (linea*==comandoGPR[i-1]){_
    _
    bien++;_
    _
    }_
    _
    }_
    _
    if(bien==6){ // If yes, continue and process the data*_
    * for (int i=0;i<300;i++){*
    _ if (linea*==’,’){ // check for the position of the “,” separator*
    * indices[cont]=i;
    cont++;
    }
    if (linea==’’){ // … and the “"
    indices[12]=i;
    cont++;
    }
    }
    mySerial.println(”"); // … and write to the serial port*

    * mySerial.println("");
    mySerial.println("---------------");
    for (int i=0;i<12;i++){
    switch(i){
    case 0 :mySerial.print("Time in UTC (HhMmSs): ");break;
    case 1 :mySerial.print("Status (A=OK,V=KO): ");break;
    case 2 :mySerial.print("Latitude: ");break;
    case 3 :mySerial.print("Direction (N/S): ");break;
    case 4 :mySerial.print("Longitude: ");break;
    case 5 :mySerial.print("Direction (E/W): ");break;
    case 6 :mySerial.print("Velocity in knots: ");break;
    case 7 :mySerial.print("Heading in degrees: ");break;
    case 8 :mySerial.print("Date UTC (DdMmAa): ");break;
    case 9 :mySerial.print("Magnetic degrees: “);break;
    case 10 :mySerial.print(”(E/W): ");break;
    case 11 :mySerial.print(“Mode: “);break;
    case 12 :mySerial.print(“Checksum: “);break;
    }
    for (int j=indices;j<(indices[i+1]-1);j++){
    mySerial.print(linea[j+1]);
    }
    mySerial.println(””);
    }
    mySerial.println(”---------------”);
    }
    conta=0; // Reset the buffer*

    * for (int i=0;i<300;i++){ //
    linea=’ ';
    }
    }
    }
    }
    [/quote]*_

o lol yeap the error =

error: expected unqualified-id before numeric constant

this part #define txPin 3

This at least compiles… you had an = in a #define, and you were missing a ; after a declaration.

#include <SoftwareSerial.h>
#include <string.h>
#include <ctype.h>

#define rxPin 2
#define txPin 3
#define ledPin 13
int byteGPS=-1;
char linea[300] = "";
char comandoGPR[7] = "$GPRMC";
int cont=0;
int bien=0;
int conta=0;
int indices[13];
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
byte pinState = 0;

void setup() {
  pinMode(ledPin, OUTPUT);       // Initialize LED pin
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(960);
  for (int i=0;i<300;i++){       // Initialize a buffer for received data
    linea[i]=' ';
  }   
}
void loop() {
  digitalWrite(ledPin, HIGH);
  byteGPS=mySerial.read();         // Read a byte of the serial port
  if (byteGPS == -1) {           // See if the port is empty yet
    delay(100); 
  } else {
    linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
    conta++;                      
    mySerial.print(byteGPS, BYTE); 
    if (byteGPS==13){            // If the received byte is = to 13, end of transmission
      digitalWrite(ledPin, LOW); 
      cont=0;
      bien=0;
      for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
        if (linea[i]==comandoGPR[i-1]){
          bien++;
        }
      }
      if(bien==6){               // If yes, continue and process the data
        for (int i=0;i<300;i++){
          if (linea[i]==','){    // check for the position of the  "," separator
            indices[cont]=i;
            cont++;
          }
          if (linea[i]=='*'){    // ... and the "*"
            indices[12]=i;
            cont++;
          }
        }
        mySerial.println("");      // ... and write to the serial port
        mySerial.println("");
        mySerial.println("---------------");
        for (int i=0;i<12;i++){
          switch(i){
            case 0 :mySerial.print("Time in UTC (HhMmSs): ");break;
            case 1 :mySerial.print("Status (A=OK,V=KO): ");break;
            case 2 :mySerial.print("Latitude: ");break;
            case 3 :mySerial.print("Direction (N/S): ");break;
            case 4 :mySerial.print("Longitude: ");break;
            case 5 :mySerial.print("Direction (E/W): ");break;
            case 6 :mySerial.print("Velocity in knots: ");break;
            case 7 :mySerial.print("Heading in degrees: ");break;
            case 8 :mySerial.print("Date UTC (DdMmAa): ");break;
            case 9 :mySerial.print("Magnetic degrees: ");break;
            case 10 :mySerial.print("(E/W): ");break;
            case 11 :mySerial.print("Mode: ");break;
            case 12 :mySerial.print("Checksum: ");break;
          }
          for (int j=indices[i];j<(indices[i+1]-1);j++){
            mySerial.print(linea[j+1]); 
          }
          mySerial.println("");
        }
        mySerial.println("---------------");
      }
      conta=0;                    // Reset the buffer
      for (int i=0;i<300;i++){    //  
        linea[i]=' ';             
      }                 
    }
  }
}

this part #define txPin 3

The cursor ends up on random, incorrect, confusing line numbers sometimes. Don't believe that just because the IDE plops the cursor on line X that's where your problem is...

G.

hey thanks for that.. i just check it right now and it does not work

Dude, seriously - you have a bunch of people here who are happy to help you out, but comments like this:

hey thanks for that.. i just check it right now and it does not work

Make us all shrug our shoulders, roll our eyes, mutter things under our breath, and then move on to posts from people who are also willing to help themselves as well by posting informed questions, and providing enough information for others to completely understand what it is you're trying to do, and what your exact problem is...

Have fun... it won't ruin my day if your project never gets completed.

G.