user4103: Now I am using ATMEGA328P and want to communicate with computer in serial using B connector female (also want to provide power from computer to ATMEGA328P using B connector). 
So here is my question. How can I connect D+ and D- to ATMEGA328P's pin No. 2 (PD0/RX) and pin No. 3 (PD1/TX)? In other words which pin should I connect to D+ and D- ? Also is it possible to connect them directly?
Thank you in advance.   

user10794: The Arduino Uno (and similar boards) have a chip on them that does serial communication via a dedicated USB chip (the ATmega16U2 chip). You can't just connect pins 2 and 3 to D+ and D- and turn that into USB.
You can conceivably do it using V-USB which does USB in software in conjunction with a few extra components.
You can also buy external serial to USB adapters which do the conversion externally. If you Google serial to usb adapter you will find quite a few for around $3.

4103: <p>Now I am using ATMEGA328P and want to communicate with computer in serial using B connector female (also want to provide power from computer to ATMEGA328P using B connector). </p>

<p>So here is my question. How can I connect D+ and D- to ATMEGA328P's pin No. 2 (PD0/RX) and pin No. 3 (PD1/TX)? In other words which pin should I connect to D+ and D- ? Also is it possible to connect them directly?</p>

<p>Thank you in advance.   </p>
 10794: <p>The Arduino Uno (and similar boards) have a chip on them that does serial communication via a dedicated USB chip (the ATmega16U2 chip). You can't just connect pins 2 and 3 to D+ and D- and turn that into USB.</p>

<p>You can conceivably do it using <a href="https://www.obdev.at/products/vusb/index.html" rel="nofollow noreferrer">V-USB</a> which does USB in software in conjunction with a few extra components.</p>

<p>You can also buy external serial to USB adapters which do the conversion externally. If you Google <code>serial to usb adapter</code> you will find quite a few for around $3.</p>
