[solved]Led not on when running fading example

Hello Forum Experts,

I am working on my first arduino project. I am having a problem while driving an12v LED with MOS Driver Module.

The issue is: the MOS Driver Module light up and fades, but Led remains off.

I've tried 'fading' and 'blink without delay' (only changed the pin), but still the same problem.

The led does light up a couple of days ago. During these two days, after I leave it a while, sometimes led works sometimes not. It's so random.
When I unplug the power supply, the mosfet led stay on for 2 sec then off.
The last time it worked was when I reconnect the arduino DC power port. (I always leave the cable connected to the port, but not powering it). Now reconnect the port makes no difference.

Components:

  1. Power supply: using external 12v power supply to the Arduino.
  2. Mosfet: https://www.jaycar.com.au/arduino-compatible-24v-5a-mos-driver-module/p/XC4488
  3. Led: 12V G4 DC 15 SMD LED Cool Warm White Disc Light Globe 5730 Halogen Lamp Replace | eBay

My circuit:

I am testing the 'fading example', only change the pin:

/*
  Fading

  This example shows how to fade an LED using the analogWrite() function.

  The circuit:
  - LED attached from digital pin 9 to ground through 220 ohm resistor.

  created 1 Nov 2008
  by David A. Mellis
  modified 30 Aug 2011
  by Tom Igoe

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Fading
*/

int ledPin = 5;    // LED connected to digital pin 9

void setup() {
  // nothing happens in setup
}

void loop() {
  // fade in from min to max in increments of 5 points:
  for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }

  // fade out from max to min in increments of 5 points:
  for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }
}

images that might help:





Really appreciate any help. Thanks in advance. :blush:

connect the GND of your Arduino to the GND of the MOS module

2 Likes

If grounds are already connected but you forgot to draw that on your wiring diagram...

Attach an ordinary 5mm led + series resistor instead of the MOSFET module. Does that behave as expected?

1 Like

does not seem so

but yes, that test is a good way to take small steps in identifying where the issue might be

1 Like

Not sure that image confirms that they are not connected. I don't think this MOSFET board has an opto-isolator, so I would imagine the GND header pin and the GND screw terminal must be connected on the board.

The power splitter cable may be providing a common ground for the mosfet driver and Arduino, although @lilyyyw did not draw a black line alongside the brown line in their diagram between the splitter and the Arduino.

2 Likes

Take your project apart. Put it back together, without cramming multiple wires into the same connectors. Use terminal strips or strips on the proto board to join multiple wires together, where one wire goes into one connector socket/screw.

1 Like

Thanks for reaching out J-M-L. :smiling_face_with_three_hearts:

Unfortunately, I tried and it didn't behave as expected.

May I ask why need to connect the GND of the MOS to the GND of Arduino, since the GND of the splitter has already been connected to the MOS GND? Thank you.

that was in case of this

ie the command logic would have been isolated from the the higher power

1 Like

Thanks for reaching out aarg.

I tried to avoid cramming multiple wires into the same connectors. (Hopefully clip is fine). And it is still not working. The Mos module lights up but led is off.


(This is the same as before, just take them off ↑)

(use the clip to combine them, to avoid multiple wires into the same connectors.↑)

Thank you.

Try adding 'pinMode ( ledPin, OUTPUT )' in setup () to the program.

1 Like

Thank you flashko

I tried and it works for 3sec.

Video link of how it looks like:

I tried a couple of times. But only the first 3 sec of the first plug in was successful.

Hi,
Can I suggest you disconnect ALL the other hardware and JUST have the LEDs output circuit connected?
And post an image of that, there are too many wires to just test the fade up and down of an LED.

Thanks... Tom.... :smiley: :+1: :coffee: :australia:

1 Like

Thanks TomGeorge.

I simplify the circuit now it only has the led.

Thanks guys. I tried modifying the code and the circuit. Now the maximum is 40pwm rather than 255pwm. It seems to be the same. Only the first two sec of the first plugin attempt works.

the video of how it works:

the code i m using now:

int ledPin = 5;    

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  for (int fadeValue = 0 ; fadeValue <= 40; fadeValue += 1) {
    analogWrite(ledPin, fadeValue);
    delay(30);
  }

  for (int fadeValue = 40 ; fadeValue >= 0; fadeValue -= 1) {
    analogWrite(ledPin, fadeValue);
    delay(30);
  }
}

What is the part number on the transistor LED driver board ?

1 Like

Is this what you are looking for?

Thank you so much guys. I think I figure this out.
I borrow my friend's multimeter, we found out that the 12v external power plug only provides 7v power, which is enough for uno board but definitely not enough for led. Led is not damaged since it works with my friend's 12v plug. I will get a new plug then.
I truely appreciate everyone's time. Have a nice day!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.