Go Down

Topic: Arduino controlled led system. (Read 8438 times) previous topic - next topic


Does anyone know of a tutorial or guide to explain the menu library?  I'm having a hard time figuring it out.

I'll look into those mosfets, there are some local electronic stores still around here so I'm going to see what they have as well.


If you scroll down on the page given there is example code. SHould be able to figure it out but basically.

* you set up all menu items as variables
* in the setup() method you add them to the correct places
* when a user selects an item it calls the method menuUsed()

you put your code in place of the Serial.println()

hope this helps


I'll have to take a look at the code again.

Also, this mosfet should work right?


That's a good logic level N-channel mosfet with lots of beef and can be controlled directly with a arduino ouput pin.



Awesome!  Because I got a $30 coupon from sparkfun during their Free Day a couple of hours ago.  Time to go shopping!


So I got my mosfets in today but when I tried to test them they just stayed "on" regardless of if there was 5v on the gate or not.  I tried running both sides (12v & gnd) through it and both times it would just turn on.  

Anyone have any ideas?


Anyone have any ideas?

Can you post a drawing and are you sure you have identified the base, source and drain terminals correctly?



I used the data sheet from the manufacturer to identify the pins, but I also used other combos of pins just to test it.

Here's the drawing of how it "Should" work according to the data sheet.

The pins from left to right are: Gate, Drain, Source


The N-Channel MOSFET wants to act as a switch for the LED ground.
You appear to be wired up for  a P-Channel MOSFET, which wants to act a switch for the + supply.

You should have this instead:
5V to resistor to gate.
12V to resistor to LED anode.
LED cathode to Drain.
Source to ground.
Arduino ground, 5V supply ground, 12v supply ground, all connected.

If you have 12V to resistor to LED Anode, LED Cathode to ground, the LED should turn on.
If not, your LED is bad, or your resistor is too high.

I would not drive a single LED with 12v, 5V is better.
With 12v, you should be driving at least 2 LEDs, 3 would be better.
With 12V you may not see the LED turn all the way off, many LEDs will not withstand that much reverse bias.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


I used one LED as an example, I'm actually running a strand of 12v leds that are made for automotive applications.

I also tried switching the ground and again the led would turn on as soon as I applied power.


Wire it as CR posted, source lead of mosfet must go to common ground.



I actually JUST figured it out.

What was happening was when I tested it I didn't have the gate attached to anything, so it couldn't "drain".  So once I put ground on the gate, it would turn off the leds.  So I'll have to add a 10k pull down resistor between the gate and gnd.


Jan 20, 2011, 06:10 am Last Edit: Jan 20, 2011, 06:13 am by retrolefty Reason: 1
So I'll have to add a 10k pull down resistor between the gate and gnd.

Yes, helps prevent a floating gate situation. It's also a safety factor to force the mosfet off in cases where the arduino might be powered off but the mosfet's external voltage is still on.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131