I am fairly new to the Arduino world. I am trying to program an ATMega328p-au for a PCB I am developing. I have run into a problem with which I'm looking for help. I have searched high and low on this site and elsewhere on the web and cannot make any progress.
I believe that I have successfully bootloaded the chip and uploaded a simple blink sketch to check to see if I can actually make the process work. Both operations were shown as successful in the Arduino software.
Here is the problem, the serial monitor shows the LED on/off actions, but the LED does not blink. I know the LED circuit is correct. Also, I have put the same sketch on an Arduino pro-mini and that works fine, so I know it is not a sketch problem.
I'm looking for suggestions on what I can do to fix this. I can provide more detail if needed.
Thanks in advance for any help that may be forthcoming.
Post the schematic.
Maybe the LED is backwards.
.
(deleted)
or broken cable.
Thanks for the replies. The LED is correctly oriented. No broken wires. I can connect the led directly to 5V and it works. I have the LED connected to pin 12 which is set as an output in the sketch. Is pin 12 the problem? Someone asked for the schematic, so I am attaching. Thanks.
Bootload Schematic.pdf (13.8 KB)
Try pin 8 since pin 12 is Arduino pin 8.
Physical pin 12 on ATmega328p is "Arduino Pin" 6 8.
So if you have connected a LED you want to toggle on physical pin 12 (like in the schematic you posted), you need some lines in your program/sketch like this
Edit: sorry, had wrong package size, the pin numbers are corrected now
void setup() {
pinMode(8, OUTPUT);
}
void loop() {
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(500);
}
Take a look at the pinout
Edit: Sorry this pinout shows the wrong package size. See next post which shows the right one
Purple/green numbers most far away from the chip are the "Arudino Pin Numbers", dark gray numbers very close to chip are the physical pin numbers.
Sorry, mine was wrong package size.
Once again, thanks for the quick replies. I apologize, but my schematic was mislabeled. I already have the pinout for the chip and have been using it extensively. I have the LED connected to Arduino pin 12 which is pin 16 of the chip. My sketch is copied below. The serial output reads "light on..." 1 sec delay "light off.." etc. However there is no output on Arduino pin 12.
I used an Arduino pro mini with the example AruduinoISP to load the chip. Could that be the problem? Is there a more appropriate bootload sketch for standalone chip?
int powerLight=12;//pin for power indicator light
void setup() {
pinMode(powerLight, OUTPUT); //set power light pin
Serial.begin(9600);
}
void loop() {
digitalWrite(powerLight, HIGH);
Serial.println("light on...");
Serial.println();
delay(1000);
digitalWrite(powerLight, LOW);
Serial.println("light off...");
Serial.println();
delay(1000);
}
Schematic (with change to a different pin for the LED) looks good, as does the code.
You selected 5V/16 MHz Promini for the bootloader?
You can also use Uno bootloader, I use that for all my 328Ps (I don't generally use A6, A7, those are not defined in the Uno bootload).
Make sure your Programmer is not connected to SCK/MOSI/MISO while your sketch is running, that might drag the pin low and keep the LED off.
Thank you for the suggestion to disconnect the programmer. I tried that with no effect. Hopefully, there are other things I might try. Is there something specific required in the bootloader for the ATMega329P-AU?