I tried to light up or blink a led on my atmel mega 328p au 1437 board. Unfortunately I couldnt do it. I tried it with arduino and with microchip studio, but none of them working. I tried a lot of yt toturial code without any luck. for example I tried the following code:
const int ledPin = LED_BUILTIN;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(ledPin, ledState);
}
}
And I got the following error:
Sketch uses 860 bytes (2%) of program storage space. Maximum is 30720 bytes.
Global variables use 15 bytes (0%) of dynamic memory, leaving 2033 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x80
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x80
Failed uploading: uploading error: exit status 1
Anybody could tell me what should I do or can give me a code that works.
There are several layers of common problems in the PC-> Arduino connection, that's just one of them.
Is the port correct and working in Windows? (COMX, no exclamation mark)
Is the driver correct?(FT232, CH340)
Is the IDE using the correct port?(Same COM as above)
Is the USB cable connected, and known to be good?
Is the correct device selected? (Tell the IDE it's a Nano, not a Mega, for example)
Is the correct processor for the correct device selected? (328 vs 168, both could be correct)
Is the correct version of the bootloader selected? (new vs old bootloader)
That's a start. I'm sure there are other gotchas; can't remember them now.
(Some of the above doesn't apply).
Is the power LED on on your Board?
yeah the port is working.
Yeah the driver is correct.
Yeah ir's using the correct port.
Yeah it's connected, cause other programs work.
I selected Arduino Board Nano.
The processor is correct too.
Actually, where can I choose thhe bootloader, cause I didn't found option named bootloader. (But I tried burn bootloader, still got the same problem)
Yeah the LED is on.
There are many, many references to choose from when looking for the CH340 driver; I usually use one referenced by one of the Nano clone vendors on Amazon, as they have a vested interest in getting their hardware to work; expecting some yt artiste to vet a source is asking for trouble.
Now my program uploads but my LED doesn't want to light up.
Anybody could link me or paste a code that would light my LED?
I would be rly grateful for it.
A different code won't help you, that code should work. Caveat - we still know virtually zero about that board, as the link you posted goes to a foreign language page. Sorry, but that's where my help stops.
Good luck!
The most likely thing at this point is that the builtin LED is broken, misconnected, or not on the LED_BUILTIN pin as expected.
Instead of using LED_BUILTIN, try connecting an external LED (plus resistor) to one of the other pins (and changing your code to match.)
The red Led is connected to D13 (the same pin where the internal Led is connected to) and the green Led to pin 12. The Leds are switched on or off at the same time.
Make sure to use a resistor (180 Ohm...1kOhm) with the Leds to protect your Arduino as in the screenshot.
You may start with just the red Led (the color is actually irrelevant) connected to D13.