Olimex/ATMega328 Reading from UART and sending to USB

arduinoatmegaserialusb

I'm getting frustrated with my electronic knowledge, because I want to do this simple thing:

Olimex 328/ATMega328 reads data from UART (Olimex MOD-PULSE or whatever) and forwards it to the USB Port (my computer).

I don't understand how I can do this. I wrote following program:

void setup()         // run once, when the sketch starts
{
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop()                       // run over and over again
{
  Serial.println(Serial1.read());  // prints hello with ending line break 
}

But it doesn't work, since Serial1 does not exist. Could you give me a hint? I can't find anything that I can understand on the Internet.

Best Answer

Apparently the site didn't like my attempt to complete my sign-up. So further to your comment on my previous answer(as user46333):

On the Uno (the board I am using for development), it is possible to communicate with the board using the UART in two ways. There is the USB connection, and there are the Rx/Tx pins (2 and 3, respectively). It is possible to connect a device (ie RS232->TTL connection) to the Rx and Tx pins to communicate serially with the controller. When the USB is connected to the computer, it communicates on the same lines, indirectly, by going through the ATmega16U2. The two connect to the ATmega328 via the same pins, as demonstrated by the RED lines in the picture below (schematic from Arduino Uno documentation): enter image description here

So to answer your question

do they read/write on the same cable?

They read/write on the same pins.

Also, to correct my code, and simplify it:

void setup() {
    Serial.begin(9600);
}

void loop() {
    if (Serial.available() > 0) {
        Serial.println(Serial.readString);
    }
    else {Serial.println("HELLO");}
    delay(2000);
}

This will receive any data sent to the controller on the Rx pin, and then immediately print it to the Tx pin.