Go Down

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

Crimson13

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.

DrogoNevets

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

Crimson13

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

Also, this mosfet should work right?
http://www.sparkfun.com/products/10213

retrolefty

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

Lefty

Crimson13

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

Crimson13

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?

retrolefty

Quote
Anyone have any ideas?


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

Lefty

Crimson13

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

CrossRoads

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.

Crimson13

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.

retrolefty

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


Lefty

Crimson13

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.

retrolefty

#27
Jan 20, 2011, 06:10 am Last Edit: Jan 20, 2011, 06:13 am by retrolefty Reason: 1
Quote
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.

Lefty

Go Up