user29755: I'm new to Arduino..
I'm currently trying to create a GPRS connection through SIM card. For that, I need to connect a serial UART port.
I don't know how to define the Serial UART. Could you please help me with that?

user313: The Arduino has only one UART which is used for program upload and for the serial terminal output to your computer. While you can connect it to another serial device that will make debugging cumbersome as 1) you won't be able to send any debug output; and 2) you will need to change it back and forth between your computer and the GPRS as you re-build and upload your code. You pretty much need a second UART to do this any kind of conveniently.
Look up the library module called SoftwareSerial which can simulate a UART on a second pair of pins, with some limitations: It is limited to communicating at 9600 baud; it can not transmit and receive at the same time; at most, one SoftwareSerial port can be receiving (or even listening) at any one time; and it can interfere with some other internal hardware, notably the interrupt system and at least one of the timers.  (The link points to the Arduino website whose documentation isn't always the very latest, but what's there will give you the idea).
In many cases, and yours is likely one of them, these are not show-stoppers, just something to be aware of as your code becomes more complex. As long as you can operate your device by occasionally sending it a string and receiving another in reply, and your system doesn't include other high-speed devices that must be serviced quickly when they request it, you probably won't notice the limitations.

user19409: In the setup function you will need to call the Serial.begin() function.
To receive a serial character you should call the Serial.available() function inside an if statement.
To send a character you can either use the Serial.write() or Serial.print() functions.
Below is a simple example program that will echo the characters back to the PC.
//-------------------------
// Simple serial loopback
//-------------------------

void setup()
{
  // initialize the serial communication:
  Serial.begin(9600);
}

void loop()
{
  byte inChar;

  // check if data has been sent from the computer:
  if (Serial.available())
  {
    // read the most recent byte
    inChar = Serial.read();
    // send back the charater
    Serial.write(inChar);
  }
}

There are plenty of "built-in" examples in the Arduino IDE that use the various serial functions. These can be viewed without any hardware attached. In the IDE go to File > Examples and from there a lot of the examples for the serial UART are in the Communications section. Details of these examples can be found on the Arduino Tutorial site.

29755: <p>I'm new to Arduino..</p>

<p>I'm currently trying to create a GPRS connection through SIM card. For that, I need to connect a serial UART port.</p>

<p>I don't know how to define the Serial UART. Could you please help me with that?</p>
 313: <p>The Arduino has only one UART which is used for program upload and for the serial terminal output to your computer. While you can connect it to another serial device that will make debugging cumbersome as 1) you won't be able to send any debug output; and 2) you will need to change it back and forth between your computer and the GPRS as you re-build and upload your code. You pretty much <em>need</em> a second UART to do this any kind of conveniently.</p>

<p>Look up the library module called <a href="https://www.arduino.cc/en/Reference/SoftwareSerial" rel="nofollow noreferrer">SoftwareSerial</a> which can simulate a UART on a second pair of pins, with some limitations: It is limited to communicating at 9600 baud; it can not transmit and receive at the same time; at most, one SoftwareSerial port can be receiving (or even listening) at any one time; and it can interfere with some other internal hardware, notably the interrupt system and at least one of the timers.  (The link points to the Arduino website whose documentation isn't always the very latest, but what's there will give you the idea).</p>

<p>In many cases, and yours is likely one of them, these are not show-stoppers, just something to be aware of as your code becomes more complex. As long as you can operate your device by occasionally sending it a string and receiving another in reply, and your system doesn't include other high-speed devices that must be serviced quickly when they request it, you probably won't notice the limitations.</p>
 19409: <p>In the setup function you will need to call the <a href="https://www.arduino.cc/en/Serial/Begin" rel="nofollow noreferrer"><code>Serial.begin()</code></a> function.</p>

<p>To receive a serial character you should call the <a href="https://www.arduino.cc/en/Serial/Available" rel="nofollow noreferrer"><code>Serial.available()</code></a> function inside an if statement.</p>

<p>To send a character you can either use the <a href="https://www.arduino.cc/en/Serial/Write" rel="nofollow noreferrer"><code>Serial.write()</code></a> or <a href="https://www.arduino.cc/en/Serial/Print" rel="nofollow noreferrer"><code>Serial.print()</code></a> functions.</p>

<p>Below is a simple example program that will echo the characters back to the PC.</p>

<pre><code>//-------------------------
// Simple serial loopback
//-------------------------

void setup()
{
  // initialize the serial communication:
  Serial.begin(9600);
}

void loop()
{
  byte inChar;

  // check if data has been sent from the computer:
  if (Serial.available())
  {
    // read the most recent byte
    inChar = Serial.read();
    // send back the charater
    Serial.write(inChar);
  }
}
</code></pre>

<p>There are plenty of "built-in" examples in the Arduino IDE that use the various serial functions. These can be viewed without any hardware attached. In the IDE go to <code>File</code> > <code>Examples</code> and from there a lot of the examples for the serial UART are in the <code>Communications</code> section. Details of these examples can be found on the <a href="https://www.arduino.cc/en/Tutorial/BuiltInExamples" rel="nofollow noreferrer">Arduino Tutorial</a> site.</p>
