Use ATmega328 as USB driver

Hello, I have two ATmega328 microcontrollers and I want to connect one directly to my PC (using USB) and use it like a USB driver (Like ATMEL MEGA16U2 works in Arduino Uno) and I want to connect it to a second microcontroller so it will receive all data that I will send using PC. How to do this?

thanks

The 328 doe's not have hardware support for USB so you can't use it in this way.

Mark

thank you Mark for replying. So I can't program atmega328 (Like Atmel MEGA16U2 is programmed as usb driver for arduino uno or any other usb driver microchip) so I could use two pins of Atmega328 as USB Data pins, and use it as usb driver which will be connected to second atmega328?

You can do, but it is a bit of a hack.

Google search for something called ‘V-USB’.

thank you very much @Tom Carpenter

Look if you want to connect a 328 to a PC vis USB then just use a pair of Uno's. Much simpler and may well be cheaper.

Yes you can connect the UARTs to each other and then talk over serial. Remember to connect the grounds.

Mark

See: http://www.hackster.io/rayburne/arduino-to-excel-using-v-usb

Gigi10012:
thank you Mark for replying.
So I can’t program atmega328 (Like Atmel MEGA16U2 is programmed as usb driver for arduino uno or any other usb driver microchip) so I could use two pins of Atmega328 as USB Data pins, and use it as usb driver which will be connected to second atmega328?

Yes, but you will most likely lose the arduino IDE automatic reset function and will have to use the ‘well timed manual reset’ method to upload to the second arduino. The first arduino should have a jumper from ground to reset so that it can’t interfere with the serial data pins. Then wiring between the two arduino is pins D0-D0, D1-D1, ground-ground pin and 5V to 5V pins.

Added note: If you remove the avr chip from the first arduino and don’t connect reset to ground then add a reset to reset wire between the two arduinos the auto-reset function should still function for the second arduino.

FTDI modules are pretty low cost, add one to your project. 2nd 328's Rx can connect to 1st 328's Tx so it can see what is going to the PC.

Can I do same with ATTiny25 (I want to connect it to computer for serial communications)?

Use it to monitor Tx from another board? Yes. Otherwise, ask a more clear question.

Umm, I might have to retract that - ATtiny25 has no UART, so you’d have to monitor with Software Serial.
I don’t if Software Serial runs on a '25 - might need a '45 or '85 to have enough code space.

ATtiny25-45-85_Datasheet-Summary.pdf (635 KB)

I have found how to use V-USB on attiny25 (http://fabiobaltieri.com/2011/10/19/fun-with-attiny-and-v-usb/) but it’s not on ‘arduino language (its not on Arduino IDE)’. So how to do this using arduino IDE?