PB: Standalone Atmega328 from Arduino Uno

Hi !

I am quite new on Arduino.
I have done a circuit for a blinking LED (with a 330Ohm resistor) with an arduino Uno on digital Pin 0 and it works perfectly (see first image).

Now I would like to have the same with the ATMega on a breadboard.

I am using the ATMega of the Uno so I am sure that the program is on it and running. I have removed the ATMega from the Uno and clip it on the breadboard. I am using the 5V of the uno board to power the ATMega (pin 7 VCC and 8 ground ) and I have attached the LED and the resistor in serie between the pin 2 of the ATMega (corresponding to the digital pin 0 of the uno) and the ground (see second attached image). But the LED is not blinking...When I attach the LED to the pin 7 or pin 20 the LED is bright.

I am probably doing something stupid...What should I do to get my LED blinking ?

The Uno has a 16 MHz external clock source, so the fuses of the ATmega328P on the Uno are set for this. Your breadboard circuit does not have a clock source so the microcontroller doesn't run. It is possible to use the internal oscillator on the ATmega328P for the clock but this requires setting the fuses accordingly using an ISP programmer.

You should also have decoupling capacitors on the power lines as close to the microcontroller as possible.

I recommend closely reading this excellent tutorial:

OK, thanks a lot !

Another question: if I use the Uno as an ISP programmer to program the ATMega at 8Mhz, will the arduino libraries such as Wire.h and SoftwareSerial.h work ?

The internal oscillator is not as precise as an external crystal so it could cause timing problems.

For ATmega328P hardware configurations different from the standard Arduino boards I recommend using MiniCore:

It's quite easy to install via Boards Manager following the instructions at the above link. You can configure it for ATmega328P with 8 MHz internal oscillator by selecting Tools > Board > ATmega328, Tools > Board > 328P / 328PA, Tools > Clock > 8 MHz internal.

You also need to be sure to always have the 8 MHz board selected from the Tools menu since if you compile for a 16 MHz board everything will be running at half the expected speed.

Note that some boards that say "8 MHz" use an external 8 MHz clock.

Note that you will not be able to program the ATmega328P without an external clock since the fuses are set for that. Once you have changed it to using the internal oscillator the external clock source will no longer be needed. It is possible to output a clock signal from the Arduino you're using as an ISP programmer and I believe Nick Gammon talks about that in the tutorial.

I finally succeed in blinking my LED on the breadboard !

I followed the tutorial pointed by pert

I didn't use the pull-up resistor nor the decoupling capacitor mentioned.

I have connect a second chip (that I hopefully had) as mentioned but failed to "detect the board". I had to wire the clock on the D9 pin (explained in the part Alternate clock source).

The I burned the Lilypad (8 MHz) loader.

And then I change to this tutorial:

I did the wiring explained for "Uploading Using an Arduino Board" and used the "ATmega328 on a breadboard (8 MHz internal clock)" setting and the LED is blinking !

Congratulations!

The pull-up resistor is not absolutely necessary because there is an internal pull-up on the reset pin but it isn't a very strong pull-up so if you have a lot of electrical noise it could cause mysterious random resets of your microcontroller. For that reason it's safest to just throw a resistor on the pin since it could save you some big headaches later trying to figure out what's going wrong.

You can sometimes get away without the decoupling capacitors but it could lead to unreliability so again it's safest to always use them.