I am making a battery level indicator for my electric four wheeler. It uses 36 volts (3x 12v batteries).
I made a circuit of an atmega328 with a 16mhz crystal, 2x 22pf capacitors also for the timing, a 100nf filter capacitor on the input power supply, and a 10k resistor from RST to +5v. Then I added 7 leds with 220 ohm resistors on them on seven different digital pins of the atmega328. Then I added a voltage divider of a 68k ohm and a 10k ohm resistor to read the battery voltage on pin A5. The whole circuit is powered by a 9v battery through a l7805 regulator.
The atmega328 already has the Arduino boot loader installed and programs just fine when inserted into an Arduino board.
I wired everything according to the official “Arduino on a Breadboard” tutorial. But nothings happening when I plug in the 9v battery.
I tested the 5v and GND pins on the atmega328 and it is reading 5v.
This may be a lot for you 9V battery. In general 9V batteries are not a desirable energy source.
Also, crystal circuits can be finicky circuits, susceptible to poor layout and noise. Usually you cannot measure the crystal with a multimeter due to loading.
I suggest,
Disconnect the LED's and run the "blink without delay". Monitor the "blinking Pin" with your meter.
@JohnRob just tested your suggestions. I changed to a 5v usb battery bank and disconnected all the LEDs. I left the one on D13 though for the blink sketch. But still nothing happened. I think it has something to do with the timing being off, but I connected the crystal and capacitors correctly.
If, when you unplug the ATmega328P chip and put it back into a Uno, it works fine there, then the obvious conclusion is that you have made a wiring error on the prototype board. Post a link to the the design you followed.
Remember that a USB battery (power bank) may have an auto shutoff feature. If you are feeding 5 volts into that circuit, that should not go through the regulator but direct to Vcc for the MCU.
I forgot to mention I had added a power LED and forgot to add a resistor on it. I didn't notice because it still lit up ok. I just checked the wiring again, noticed that it was missing a resistor, desoldered it and tried it again, and it is working perfectly!
Either your schematic is wrong, or that is not a voltage divider, unless you are relying on the internal resistance of the analog input to form a voltage divider with the 68K resistor (R2). The 10K resistor (R3) serves no purpose.