You can use eFirmata to control some RGB lights from a smartphone:
Controlling RGB lights from a smartphone.
We will use a PHP script as an intermediate step:
All of this code is in the directory:
(It would certainly be possible to build an app directly for the phone, which sends UDP packets directly to the eFirmata.)
Hardware: getting started
To start, we'll use some simple, regular LEDs. You can test your setup before buying any expensive, high-power LEDs.
This is the schematic:
The simplest LED circuit (for regular, little LEDs).
Resistors should be around 1K or 300 Ω or so.
Driving High-powered LEDs
The mbed itself (ie, the LPC chip itself) can only drive 3.3 volts at (perhaps) 10s of milli-amps. So if you want to power your 10 watt blue LED (and, who doesn't, really), you're going to need an output stage. An excellent solution is with a modern N-Channel MOSFET.
Driving a 12 volt LED
If you're using power LEDs that can be connected directly to a 12 volt power supply, (or even plain, ol', 12 volt lightbulbs), then the circuit is very simple:
12 volt LEDs (or even plain-old 12V lightbulbs) controlled via N-Channel MOSFETs
For our MOSFETs (Metal Oxide Semiconductor Field Effect Transistor), many different MOSFETs will work just fine, but there's a few parameters to keep in mind:
- N-Channel (power) MOSFET
- Vgs(th) less than 3.3 volts.
(The LPC is a 3.3 volt device, so the transistor gate must respond to 3.3 V or less)
- Id more than a couple amps.
(For example: if your LED (or lightbulb) uses 1.3 amps, the Id must be greater than 1.3 amps. (10x greater is a safe way to roll.))
- Rds(on) as small as possible.
The smaller it is, the less heat the mosfet will produce (ie, the more energy-efficient the circuit will be). Modern power mosfets have a typical Rds(on) of less than 0.010 Ω or so. Don't waste your money on anything with a higher Rds than that. (There's plenty of older transistors to avoid.)
- Operating frequency of much more than 25 KHz. Most, most, most modern transistors can do this just fine. (The mbed PWM operates as >25 KHz. I've never seen a mosfet that can't handle this.)
If you follow these criteria, then any N-channel MOSFET is just as good as any other N-Channel MOSFET.
Driving less-than-12-volt (but still high-power) LEDs
Some high-powered LEDs cannot be connected directly to a 12V power supply. In this case, you'll need something to limit the current (like a resistor, for example). You'll probably have to use Ohm's law to figure out what value of resistor you need. (Also, keep in mind that you'll probably have to use a higher-wattage resistor...)
Some high-power LEDs still need resistors to limit the current.
Resistor values will vary. (Right now, I'm using a setup with 1 Ω, 3 Watt resistors.)