I’m working on a custom base for a model kit and I want to turn on/off the power to my Arduino board(s) with both a momentary button on the base and a custom remote (IR). Essentially, this will be similar to a typical device like a TV where you can toggle on/off the power either via the button on the device itself or its remote. The model will run off 12VDC via wallwart, so the base (and hence the Arduino board(s)) will always have power.
I have no idea where to start with the power-related parts/code for this. I know I need an IR remote control and an IR receiver, but where I need help is how to connect both the momentary switch and a … relay? solenoid? to pass the 12VDC on to the model’s Arduino boards.
Hi Ross. Thanks for your post!
What you’re going to need is an Arduino that lives in the base and is always on. That will have a button and IR receiver diode connected too it and will run a sketch that monitors both the button and IR receiver. When either receives a push or valid signal, you’re going to have your sketch toggle one of the Arduino’s I/O pins high or low. Connected to that pin would be a relay and the relay would then connect or disconnect power to the attached model.
For IR control, I’d recommend starting with our Infrared Control Kit. It has the receiver diodes you need plus a small IR remote, hookup guide and some example code to get you started. For a button, any momentary push button we carry will work, but you might consider a button like our metal lighted buttons. To actually switch power on and off, our Beefcake relay control kit would work. Finally, for a Arduino, I’d use our RedBoard.
- [[SparkFun Infrared Control Kit](https://www.sparkfun.com/products/14677)
- [[Metal Pushbutton - Momentary (16mm, Red)](https://www.sparkfun.com/products/11966)
- [[SparkFun Beefcake Relay Control Kit (Ver. 2.0)](https://www.sparkfun.com/products/13815)
- [[SparkFun RedBoard Qwiic](https://www.sparkfun.com/products/15123)
[/list]
I don’t have any example code for the entire finished project, but the hookup guides for the Infrared and relay kits should have most of what you need, you just need to combine the code for both. For using a button, the tutorial and video below should give you an idea what you need to do code wise.
- [[Arduino Pushbutton tutorial](https://www.arduino.cc/en/tutorial/pushbutton)
- [[Arduino uno Toggle button with led on and off tutorial](https://www.youtube.com/watch?v=XQzQFwpnhRo)[/list]](https://www.youtube.com/watch?v=XQzQFwpnhRo)](https://www.arduino.cc/en/tutorial/pushbutton)](https://www.sparkfun.com/products/15123)](https://www.sparkfun.com/products/13815)](https://www.sparkfun.com/products/11966)](https://www.sparkfun.com/products/14677)
Thanks Chris! But do I need something as big as the Beefcake Relay Control Kit if I’m only latching 12VDC (2-3A)? Is there something simpler, and smaller?
Hello Ross.
Depends on what you’d call simpler. The Beefcake has everything you need on one board, but you could always make your own, smaller board, or you could use something like the [Qwiic Relay. The Qwiic relay is simpler hardware wise, but a little more complex to code for. You might have a look at it’s hookup guide to get a feel for how it works.
If you want to use a smaller relay and not go with the Qwiic relay, you’d still need to reproduce the driver circuit that goes between the relay and Arduino.
Most relay’s need more current than an Arduino pin can provide so a transistor would be needed to boost the output. You’ll also need a [diode across your relay’s coil to protect the transistor and Arduino from inductive kickback when the relay turns off.
If you look at the schematic for the Beefcake kit, you will see how to connect the parts you need. (2N3904 transistor,1K resistor, and a 1N4148 diode) We carry those parts on the website and they should be pretty easy to find in the search bar. For a smaller relay, [one of these would work with those parts and is quite a bit smaller than the relay used in the Beefcake.](https://www.sparkfun.com/products/100)](Flyback diode - Wikipedia)](https://www.sparkfun.com/products/15093)