Can't get LED's to illuminate

The attached PDF file is a program that I wrote in May 2019 to control my model railway switches (using servos) and their corresponding signals (using LED’s). The code is loaded on a Mega. The code has worked perfectly until I attempted to add an additional signal. The second signal identified as “yardLed2PinRED” should mimic “yardLedPinRED” and “yardLed2PinGRN” should mimic “yardLedPinGRN”. Both the led’s on signal 2, do not illuminate under any circumstance.

I have done the following to attempt to troubleshoot the problem.

Using an independent power supply, I checked the signal and the associated wiring right up to where it plugs into the Mega. The led’s light at both 3.3 volts and 5 volts.

Using “digitalRead”, I confirmed that the pins are going high and low as necessary. The original portions of the code still runs perfectly.

I can’t figure this out so I would appreciate any assistance.

Thanks,

Dave MacLeod

Railway Signalling.pdf (40.7 KB)

More members will see your code if posted properly. Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

What happens if you run the Blink example with the output pin set to the LED that you have added ?

I loaded the blink code on the Mega. The signal leds did not blink. I then loaded the blink code on a Nano and hooked up the signal. It successfully blinked both leds. I reloaded my signalling code on the Mega, hooked up a voltmeter to the assigned pins 35 and 37. They both showed 4.7 volts when they were supposed to. It is my understanding that leds are current driven. Could it be that the Mega is not delivering enough current?

Dave MacLeod

No. The Mega outputs are almost identical to the Nano. You have no response to reply #1? You can post your LED test code, and clear images of your hardware connections.

it was the blink code that is in “files/examples/basics” in the arduino IDE

davermacleod:
it was the blink code that is in "files/examples/basics" in the arduino IDE

But that blinks one LED and does not use your LED pins. What did you change ?

Hi,
Ops Railway Signalling code attached as ino.

Thanks… Tom… :slight_smile:

Railway.ino (9.23 KB)

Hi,
Try this bit of code;

int LED35Pin = 35;
int LED37Pin = 37;


// the setup function runs once when you press reset or power the board
void setup() 
{
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED35Pin, OUTPUT);
   pinMode(LED37Pin, OUTPUT);
}


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

Tom.. :slight_smile:

Hi Tom,

Hi Tom,

I ran your code example and the LED's did not light.

Check your grounding to the Arduino.

davermacleod:
Hi Tom,

Hi Tom,

I ran your code example and the LED's did not light.

Then I suspect that you have a wiring issue. Can you measure the voltage at the pin and at the led?

Very often, when detailed images of the hardware are posted, someone spots the problem within a few minutes... just saying...

Hi,
Can you please post a picture of your project so we can see your component layout?

Thanks.. Tom... :slight_smile: