Go Down

Topic: How to declare a serial device by USB connection on Arduino (Read 967 times) previous topic - next topic

tlslaj0417

I am connecting a serial device to arduino by USB. So may i know how to declare its baud rate,port,etc...on arduino? Is there any way to do it? thanks if any replied. :)

PaulS

Quote
So may i know how to declare its baud rate,port,etc...on arduino?

Set the baud rate using Serial.begin(). The port is defined by which pins you connect to. The USB cable is connected, via a USB-to-serial chip, to pins 0 and 1 which are hardcoded to the Serial instance.

tlslaj0417


Quote
So may i know how to declare its baud rate,port,etc...on arduino?

Set the baud rate using Serial.begin(). The port is defined by which pins you connect to. The USB cable is connected, via a USB-to-serial chip, to pins 0 and 1 which are hardcoded to the Serial instance.

1st, thanks for replied!!:) sorry for a beginner question:
as i am just using USB connection, connect a board to Arduino Uno by USB. how do i defined the port and other info such as in a serial terminal in linux? my code:
Code: [Select]

EVAL_SERIAL_RATE = 57600;
void setup() {
  Serial.begin(EVAL_SERIAL_RATE);
}
void loop() {
  if (Serial.available() {
    byte test = Serial.read();
    Serial.print("I get first at: ");
    Serial.println(test);
  }
}

so i now i only know how to begin a baud rate, how about the port?

PaulS

Quote
so i now i only know how to begin a baud rate, how about the port?

I don't understand the question, I guess. A PC can have multiple devices connected to it, and each connection creates a new real or virtual COM port. The code running on the PC needs to connect, then, to the correct port.

The Arduino has only one real, and no virtual, serial port. So, there is no need to "define the port". It simply is.

tlslaj0417


Quote
so i now i only know how to begin a baud rate, how about the port?

I don't understand the question, I guess. A PC can have multiple devices connected to it, and each connection creates a new real or virtual COM port. The code running on the PC needs to connect, then, to the correct port.

The Arduino has only one real, and no virtual, serial port. So, there is no need to "define the port". It simply is.


i think i get what your mean, is that mean the arduino has only one real port. so we have no need to define the port? Lets say in the PC, when i am connected to the board by USB, i need to set the baud rate and port number in the serial terminal so that i can see the data on the board. Instead of PC, i am connecting arduino Uno to the board. So I just wondering how i going to access the board. For example in pc:
I type R 32 to read the register value follow by guide in:
http://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXLEvalBoard%20User_Guide2009-09-14.pdf in page 4.
In another way, i connect arduino UNO to the eval board. How i going to program the code so that arduino will keep requesting data from the eval board??

thanks for consider my question. Thanks again

Go Up