1

I am just starting with Arduino and was trying to make the LED example work. I changed the script as follows to keep the LED on:

#define LED_PIN 12
#define LED_RX_SIG LED_BUILTIN

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_PIN, OUTPUT);
  pinMode(LED_RX_SIG, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_PIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  //delay(1500);                       // wait for a second
  //digitalWrite(LED_PIN, LOW);    // turn the LED off by making the voltage LOW
  //delay(1500);                       // wait for a second
  //digitalWrite(LED_RX_SIG, HIGH);
  //delay(1000);
  //digitalWrite(LED_RX_SIG, LOW);
  //delay(1000);
}

I setup the Nano board, LED and a 220ohm resistor on a breadboard. The D12 port on Nano is connected to one end of the 220ohm resistor using a jumper cable. The other end of the resistor is connected to the positive (longer end) of the LED. The negative end of the LED is connected to the GND pin on Nano. The setup is shown in the image below:

Nano Board Setup Top View

enter image description here

What's wrong with the setup and why the LED is not lit? Sorry in advance for such novice question and any help will be greatly appreciated. Thanks

3
  • 3
    You didn't ask any question. What is the problem with this circuit?
    – chrisl
    Jun 24, 2019 at 15:03
  • 2
    Try and connect the red wire to VCC (instead of D12), to verify that the led works. The code looks fine to me. You can also try a different pin than D12. There might be a bad solder connection on D12. There's a lot of trial and error involved with Arduino.
    – Gerben
    Jun 24, 2019 at 15:28
  • @chirsl thanks for pointing it out; edited my post and added the relevant question Jun 24, 2019 at 16:20

2 Answers 2

3

As your program is currently written, you should see your LED light. I see nothing wrong with your program or your wiring. I am also assuming that you had no errors while compiling and downloading the program.

With the rest of the lines uncommented, what you should see is your LED light up for 1.5 seconds and then off. Then after another 1.5 seconds, the on-board LED should turn on and then off (both 1 second).

If you have wired up the LED wrong (or a bad connection), you should at least still see the on-board LED flash about once every 5 seconds. If you don't see this then something else is wrong.

One thing I notice from the photos is that you have no way of powering your circuit. (I realise this may just be while you took the photo). Plug a USB cable into the Arduino and the other end into the computer. You should see the LED called "POW" light up.

To verify your LED circuit, try disconnecting the jumper at D12 and connecting it to 5V and you should see the LED light. If this works then your circuit is OK so replace the jumper back at D12.

If the LED still does not light up when the jumper is connected to 5V then we need to dive into that circuit. Possible reasons include:

  • The LED is dead -> replace the LED
  • The breadboard is not making good connection -> wiggle the leads (to scratch away any corrosion) or twist together the wires where possible or even solder them together.
  • The jumper wires are manufactured poorly (eg. the plastic wasn't stripped before crimping) -> check the jumper crimps.
  • The LED has been manufactured wrong and what should be the anode is actually the cathode (I have seen this) -> reverse the polarity of the LED.
  • The resistor is burnt out -> replace the resistor.
4
  • Thanks for the answer. With the lines uncommented,I do see the on-board LED flash roughly about every 5 seconds. I added that earlier to check if the circuit is receiving code. Also, it compiles successfully and also uploads without error. I tried the 3V pin, 5V pin. Still no LED. What can be wrong with the circuit? I watched a lot of videos on Youtube that used a similar circuit. I am not sure how to troubleshoot these problems. FYI, also tried D11, D10 and D9. Didn't work. Jun 24, 2019 at 17:22
  • 1
    @AbrarHossain I have edited my answer and included more information to the end.
    – sa_leinad
    Jun 25, 2019 at 0:59
  • 1
    Did the extra information help? Did you get a solution to you problem?
    – sa_leinad
    Jun 25, 2019 at 14:02
  • 1
    @sa_leinard Here's what I have done so far. I bought a new Nano board, used new jumper cables and a new 220ohm resistor. Finally, the LED is blinking. Thanks for all your help. I believe the problem may have been with any of the components I replaced. I will try to debug exactly which caused the problem and update the question. Jun 25, 2019 at 14:43
1

If your led does not turn on after you directly connect it to the VCC and the GND (as you mentioned in a comment) , it means that your led is most likely broken. Simply try using another Led as your circuit and code look fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.