LEDs make everything better, including RC Cars! Draft!
Step one: determine the states.
Headlight brightness: Off / Med / High OR analog
Right turn: On / Off
Left turn: On / Off
Movement state: Forward / Brake / Reverse
We have 36 states (3*2*2*3) OR 12 states + analog
Step two: Figure out how to communicate the states.
The movement state is fairly easy, we can get that by reading the throttle channel from the receiver. (Chan 2 in my case) The slightly more difficult part is communicating the other states with a cheap transmitter. The best way would be to map the analog value of the headlights from (as an example) channel 3 and then pull the turn signal from channel 4. But… I had already taped a 3 channel receiver into the RC car. Sure, I had a couple 6 chan receivers that I could have put in easily, but what is the fun in that? Not to mention that the pulseIn() function can take up to 20ms and the only way to prevent that delay is to use interrupts. Using 2 channels and not dealing with interrupts gives us a moderately acceptable 25Hz update rate. As a result I decided to map the turn signals and headlights onto channel 3.
Step 3: mapping
This is how I mapped it:
4: Choosing the LEDs and how to drive them
The signal LEDs don’t need to be very bright, so we can figure the standard 5 mm @ 20 mA driven from the ATMEGA is fine for everything but the headlights and backup lights. Unfortunately, that adds up to 7 pins (2 front turn + 2 back turn + Brake/running lights + headlights + backup lights) and the arduino uno (and nano) only have 6 PWM pins. We could choose to move some of the pins (like the turn and backup Lights) over to regular pins, but I decided to go with a strip of WS2812 lights on the back. This gives us more options, and contains an integrated driver. This reduces us to 3 PWM pins! I could even drive the headlights independently, but then I would need two FETs and it is kind of pointless.
The motor controller contains a 5V 2A BEC which should be plenty, but let us brake it down.
-800 mA for the servo (Stall current, should be less in normal operation)
-400 mA for the WS2812 LEDs (50 mA * 8)
-40 mA for the front turn signal
-50 mA for the arduino nano (probably less)
-600 mA for the headlight LEDs [Note]
Which adds up to 1.89 Amps max current pull, which is less than 2A but I don’t know how much the receiver or motor controller use. I suspect it would be fine, but we have something else to worry about with the headlight LEDs anyway.
The LEDs I got for the headlights are rated “3.0-3.3V” and “300MA” [sic] so we can:
–drive them at 5v off the BEC with resistors which would be 600mA total and dissipate 1.2W over the resistors. But, we would need 1W resistors.
–Use a LED driver or DC/DC converter to pull 400-500mA off the 5V BEC. This would probably be the best choice, but we aren’t doing a large run or SMD, plus our current consumption is a bit large so…
–Bypass the BEC completely and use a 3.3V DC/DC converter off the battery with a small valued resistor (1Ω) to the LEDs.
This brings us down to 1.29 A off the BEC leaving a lot of headroom.
6: Simplified wiring diagram