Pages: 1 [2]   Go Down
Author Topic: Arduino controlled led system.  (Read 4403 times)
0 Members and 1 Guest are viewing this topic.
suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

South East England
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty
Logged

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26570
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Lefty
Logged

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 
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
« Last Edit: January 20, 2011, 12:13:45 am by retrolefty » Logged

Pages: 1 [2]   Go Up
Jump to: