Need help getting started with ATmega168 standalone

I am trying to program an ATmega168-20PU microchip with a sparkfun pocket AVR programmer. I have it set up on a breadboard with no external crystal or other circuitry. I've followed several tutorials and I'm pretty sure I at least have it wired up correctly, as I am able to communicate with the chip through avrdude command prompts. I've been trying to program it to cause an led to blink using the Arduino IDE and Atmel studio. I downloaded avrdude because some sources said it's necessary.

I'm afraid that I've gone down so many dead ends with this project just trying to load the simplest program that I'm totally lost and I don't know what is necessary to load something with my setup. The end goal is to run the micro with a 16 MHz crystal, but right now I can't get it to run with even the internal oscillator.

Any help is much appreciated.

My Sparkfun Pocket AVR programmer

Pics of my setup:


It sounds like you're making this unnecessarily complicated by messing with Arduino IDE and Atmel Studio. Pick one and stick with it until you get it working. After that you can try it the other way if you like. I'd recommend using the Arduino IDE. I'm biased but I think you'll also get more help here with using the Arduino IDE.

MegaKrispy:
I downloaded avrdude because some sources said it's necessary.

avrdude is included with the Arduino IDE so no that is not necessary if you're using the Arduino IDE. I don't know about Atmel Studio.

We need a better picture of your setup. I can't see how the crystal is connected. You should have the crystal as close to the microcontroller pins as possible, as shown at:
https://www.arduino.cc/en/Main/Standalone

You are missing decoupling capacitors.

Please describe exactly the procedure you're using.

Sorry for the confusion. As I said, I'm not using the crystal. It's just on the board for safe keeping and is not connected. The decoupling capacitors are there but you can't see them well.

The reason I used both arduino IDE and Amel studio is because I've tried both individually and neither worked.

The large metal thing you see is a button with a built in led and resistor for testing. The setup is really as simple as it looks. Just a USBtiny programmer plugged into my laptop and connected to the microchip.

I can clearly see all the holes where you could put a decoupling cap and have it work. There is no decoupling cap.

Connections to the decoupling cap need to be short. I have had to throw away custom manufactured circuit boards because I screwed up the placement of a decoupling cap, and it wouldn't program without dead-bugging a cap on top of the chip. Decoupling caps should be right next to the chip.

Same goes for crystal, btw. Crystals and decoupling caps are pretty much the only layout-sensitive thing you'll encounter in hobby electronics, but you encounter them fast if you're trying to do standalone microcontroller projects instead of using a professionally assembled board.

You also presumably are encountering errors when you try to program it. Please post the full text of any and all error messages you receive (you should do this whenever you ask for help with any problem where an error is shown).

Are you using a custom core? I recommend Hansibul's minicore for 88/168/328 standalone projects, rather than trying to do it with the built-in board defs. You must be doing something because out of the box the Arduino IDE doesn't support boards using internal oscillator.

DrAzzy:
There is no decoupling cap.

Yup, I misunderstood. It's there for real now.

I have the ISP header, but am I also going to have to buy the FTDI header? Do they both plug into my laptop at the same time?

I downloaded the core you recommended and tried it. Here is the error message I get when trying to burn the bootloader using the arduino IDE and no FTDI header:

avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Kris\Documents\ArduinoData\packages\MiniCore\hardware\avr\1.0.3/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATmega168P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no        512    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Error while burning bootloader.
Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406 (probably m168)
avrdude: Expected signature for ATmega168P is 1E 94 0B
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

MegaKrispy:

avrdude: Device signature = 0x1e9406 (probably m168)

avrdude: Expected signature for ATmega168P is 1E 94 0B

Now we see the problem. A little effort to provide us with information goes a long way. You have an ATmega168 but you're telling AVRDUDE it's an ATmega168P. Use MiniCore:

which has an ATmega168 option as well as internal oscillator.

OK, update: I got an led to blink! Thanks for the help, I'll start a new thread if I need anything else.