Its a simple question. I have serial data coming into my Arduino and going out of my Arduino. In the case where I do not use #include<SoftwareSerial.h> ,can I connect my RX pin0,TX pin 1 to my receiver TX,RX pins respectively? I do understand the internal ciruitry of the Arduino[http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf] but I read somewhere that pin 0 and pin 1 are internally connected to the USB port,hence making it unusable with the USB connected at the same time.
That's correct. They are connected to the FTDI chip that handles USB to TTL conversion for communication with PC. You can't use them for another function but you can use your USB and the serial monitor to monitor what you are using them for.(meaning you can't do anything different with the USB while you're doing something with 0 & 1 but you can monitor what your are doing with 0 & 1 on the serial monitor (using serial print statements).
What did you mean by "you can't do anything different with the USB while you're doing something with 0 & 1"?
Scenario: Its serial communication over a single cable line(LIN bus).So,my USB sends out signals and also receives signals after a delay on this single line. In this scenario,from what you said above,I conclude that I should not write something like this?
SoftwareSerial Serial2=new SoftwareSerial(0,1) //where O is RX and 1 is TX
Instead I write something like this?Is that correct?
SoftwareSerial Serial2=new SoftwareSerial(2,3) //where 2 is RX and 3 is TX
I'm a beginner.
I was told the USB is a SLAVE port and can't be used by an application for serial because it is also connected to 0 and 1, hence the need for soltware serial. If you can get it to work , more power to you but according to what I was told if you try to write to code to use it as if it were a HOST port and not SLAVE, it won't work. I guess you'll find out. If you need a HOST USB port you have to get a USB shield
Why would they sell this if what I said above were not true ?
Why would you use SoftwareSerial(0,1) when 0,1 are the hardware serial pins? If you want 0-5V level serial to something else, unplug the USB cable and go ahead and use normal Serial.begin(speed); to access 0,1 as the normal hardware port.
If you leave the USB cable plugged in and open the Serial monitor, to the same data rate then you can also monitor what the processor sends out (on Tx).
Yes, 0 and 1 are connected to the USB/Serial adapter (FTDI chip on older (2009) boards, and Atmega8U2 and then 16U2 on cards since then), but with a 1K series resistor, which acts like a pullup resistor - so if you want to use 0 & 1 for other stuff you can; the '328P (or 2560 or 32U4) has 20mA output drive capability and can override the pullup, and any external device will need a couple mA of drive capability to pull the pins low if 0,1 are used as inputs.
Maybe I misunderstood them but I thought they were asking if they could use the USB for one thing and 0 & 1 for something else in the same application.(in other words, use the USB as a HOST port).
0,1 can only be used for one purpose at a time. If the USB port is being used for serial comms with a PC for instance, then 0,1 are committed and can't be used for something else, like Software Serial.
The standard Uno cannot be used as a Host device, its USB interface is as Slave only.
When a Host shield is added, then SPI comm's to a MAX3241E (I think) USB Host chip provide limited USB Host capability. Last I looked, not a lot of devices were supported yet.
When the 16U2 is reprogrammed for HID support (mouse, keyboard, joystick) I don't know if that is considered USB Hosting, but I don't think so.
Thanks for clearing that up.
Yeah, after I went and muddied it up some first 8)
You can use them if what you connect to them doesn't put any load on the pins.
If it puts a load on the pins it will corrupt the serial data and you won't be able to upload any sketches.