I'm learning Arduino. I use Arduino Uno board with ATMEGA328-PU. I tried basic codes like LED blink, control of DC motor etc. Arduino board is used only when we program microcontroller, right? I mean, when we finish programming it, we can use microcontroller separately? If it can be used separately, we must have some "external" circuit as replacement for Arduino board, which allow us to use microcontroller in specific application. What type of circuit is used? I'm new in this field so don't blame me because of amateur questions.
Assuming you are going to upload the program into the ATmega328 on the Arduino, then take the ATmega328 out of the socket, and use it in your circuit, then a simple answer is to search for "minimal Arduino circuit"
An example returned by that search is "From Arduino to a Microcontroller on a Breadboard".
- a 16 MHz crystal,
- a 10k resistor, and
- two 18 to 22 picofarad (ceramic) capacitors
That is enough to run the chip at the same speed as the Arduino, and the code used on the Arduino to initialise its clock will work unchanged.
This should run okay directly from a battery supply of about 4.5V or 4.8V, or a good 5V power supply.
A better circuit, which runs at the same 16MHz speed as the Arduino is 'Shrimp It'. That shows a similar minimal circuit and a better 'protected' circuit which has a more reliable approach for its power supply. This is all you need to run off a 4.5V (e.g. 3 1.5V) battery power supply.
However, if you don't care about running at 16MHz, you could ditch the crystal and capacitors, and use the internal 8MHz oscillator, that will need the code to be slightly different. For example, the 8MHz clock is 1/2 the speed of the Arduino's standard 16MHz, so code like
delay() will take 2ms instead of 1ms.
Further, the RESET button can be set up so it doesn't need the 10k pullup.
So, with some software changes (search the web for details), an ATmega328 could be used with no external components.
Alternatively, you might want to use a better power supply, for example a voltage regulator with the circuit of the protected 'Shrimp It', and be able to load the program onto the ATmega while on its board.
There are products which bundle that 'standard' set of parts (voltage regulator, plugs and sockets and protected 'Shrimp It' running exactly like an Arduino at 16MHz) with a very compact PCB. They are able to plug directly into a breadboard, and so can be used with veroboard/stripboard (or a PCB) to make the rest of the circuit.
Neither Boarduino nor RRRB has on-board USB upload circuit. However, you can use your Arduino to do that, for example "Using an Arduino as an AVR ISP (In-System Programmer)". Or you could buy a USB to UART cable.
There are two approaches to this. One is to simply use the Arduino Uno board in your final product! However, if you're making a large number of boards, it may be more cost efficient to develop a custom board with only the features you need. It may be nothing more than a few GPIO pins and a power regulator!
Another thing which can be important in these final products, no matter what board you are using, is that you can permanently burn your program into memory so that it always starts up when power is applied.
Look at the schematics and see which bits you don't need. Leave those out and what's left is what your require. You then would need to design a circuit board for these parts.
Now, who should we blame for your amateur questions? ;^)
Arduino board is used only when we program microcontroller, right?
Not necessarily. The Arduino board is useful not only for programming, but because it provides required peripheral circuitry such as power regulation, USB-serial interface, convenient headers, and a crystal.
However, it is perfectly fine to use the Arduino board to program your ATmega328 and then take it out and use it in another circuit.
If it can be used separately, we must have some "external" circuit as replacement for Arduino board, which allow us to use microcontroller in specific application. What type of circuit is used?
All the ATmega328 really needs is a stable power supply. If you're alright running it at 8MHz, you don't need an crystal. If you don't need in-circuit programming, you don't need an ISP connection or any USB-serial stuff.
For more powerful microcontrollers, you might require clock generation circuitry, multiple power rails, debug/programming connections, etc.
See this page on how to put an ATMega329 chip on a breadboard and have it run. I think this will explain things: https://www.arduino.cc/en/Main/Standalone