• EUR€
  • £GBP
  • $USD

Limit TV Time with an Arduino-Controlled Relay

DFRobot Sep 18 2015 301

Most of us spend far too much time in front of the TV. So I designed a system that will automatically limit when and how much the TV can be on.

The system works by controlling the input signal going to the TV. This is done by adding a relay switch to the input cable. When certain conditions are met, the relay is turned on and the TV is able to receive the input signal.

Using an Arduino microcontroller, you can program the system to only allow the TV to be on for a certain amount of time each day or between certain hours. You can set up a PIN code so that only certain people can turn it on. You could even set it up so that the TV will not turn on unless you have done a certain amount of exercise that day.

The system is very versatile and can be customized to fit your needs.

Step #1: The control circuit
  • The control circuit for this project is very simple. It's basically just an Arduino microcontroller and a 5 volt relay. In order to power the relay directly from the Arduino, the coil of the relay needs to be rated for 30 mA or less. If your relay requires more than 30 mA, then you need to add a transistor to drive the relay. The normally open terminal and common terminal of the relay are connected to the input cable. The coil of the relay is connected to one of the digital pins and one of the GND pins on the Arduino. A diode is connected in parallel with the coil of the relay to protect the Arduino from voltage spikes that can occur when the relay turns off.
  • Normally the digital pin is set LOW. This means that the relay is turned off and the two halves of the input wire are disconnected. In this state, the signal cannot reach the TV. But when the digital pin is set HIGH, the relay turns on and connects the two halves of the input cable. This is how the Arduino determines when the TV receives the signal from the input device.
Step #2: Select the appropriate connector cable

The first thing that you need to do is get a connector cable that matches the input terminals on your TV and the signal source. The most common types are Coaxial cable, RCA cable, and HDMI cable.

Step #3: Cut the cables and remove the outer insulation
  • Next we need to cut the connector cable in the middle. Then strip off about 2 inches of the outermost layer of insulation to expose the first layer of internal wires. Separate and peel back these wires to expose the next layer of insulation. Strip off about half of this exposed section of insulation. This will reveal the inner wires. Twist the first set of wires together. Then twist the second set of wires together. You should now have two separate strands of wires that you can connect these wires to a relay switching circuit.
  • This simple procedure will work well for RCA cables and coxial cables. However, HDMI cables are a little more complicated. There are a lot of wires inside an HDMI cable. If you want to try to manually separate the wires of an HDMI cable you will need a lot of time and patience and you need to be very careful. An alternate method that might make things easier is to use an HDMI break-out board.

Step #4: Solder the relay circuit together
  • Start with a blank piece of perf board. Solder the relay onto one side of the board. Then solder the diode onto the board adjacent to the relay and connect the leads of the diode to the coil terminals of the relay. Next you need to connect the wires from the input cable.
  • The innermost sets of wires can just be soldered back together by attaching them to adjacent holes and connecting them with a bead of solder. The outer set of wires in each cable will all be grouped together. With RCA cable these wires are all connected together as a ground. So it won't affect the signal. These wires are soldered to the board. Then a jumper wire connects them to the switch terminals of the relay.
  • The last connections to make are the wires that will connect to the Arduino. Connect one wire to each terminal of the relay's coil.

Step #5: Connect the relay circuit to the Arduino

Now you need to connect the relay circuit to the Arduino. Connect the wires from the relay board to the Arduino so that the anode of the diode is connected to one of the GND pins on the board. Then take the wire that is connected to the cathode of the diode and plug that into one of the digital pins on the Arduino board. It is very important that you get these polarities correct. If you accidentally reverse them, you could destroy the Arduino.

Step #6: Mount the parts inside an insulated project enclosure

Find a large insulated project enclosure. Then attach the relay circuit and the Arduino to the inside of the housing with a small drop of hot glue. A small drop of hot glue will be just enough to hold the boards in place but still allow you to remove them later if you want. Cut holes and slots in the back of the housing for the cables and power cords and sensor wires.

Step #7: Decide how you want the TV to be controlled
  • Now you need to decide on the set of conditions that will allow the TV to be connected. There are a lot of ways that you can do this.
  • The simplest method is to use a timer. For example the TV will only be connected between certain hours (such as 6 p.m. to 8 p.m.). Another option is to set a certain number of hours each day that the TV can be on. This limits the number of hours like the first option, but is not restricted to a certain time of day. You can also create pass codes that will only allow certain people to turn the TV on. If you want to make sure that your family gets more exercise, you can set up the system so that the TV will only turn on if you have done a certain amount of exercise that day. The possibilities are endless.
  • In the next few steps, I will give some examples of how you could set the system up in different ways.

Step #8: Use a simple window timer to activate the TV
  • The simplest kind of control program is a window timer. Here is a very basic example of this. Once the system is activated, the TV will be connected for 1 hour (3600000 milliseconds). Then it will be off for 23 hours (82800000 milliseconds). This will create a one hour window each day where the TV can be watched. You can easily change the timing of this by changing the values in the code.
  • Alternatively, you could set up a button to activate the TV watching time. This would let the user select when the TV may be on but still limit the total number of hours per day that it is on.

Step #9: Set up a pass code for authorized users to activate the TV

Another variation on the design that you could implement involves setting a pass code so that only authorized users can turn the TV on. This can easily be done with the TV remote. All you need to do is add an infrared receiver to the Arduino. You can check out an example of how to do that here.

You can either use a single key button as in the example, or you can create a secret combination of buttons that will activate the TV.

Step #10: Create a sensor to only turn on the TV if you have exercised
  • My favorite way to control a TV limiting system is with exercise. The simplest way to do this is to set up a sensor on an exercise bike that will send a signal to the control circuit when someone is pedaling. This will let you program the system to only let the TV be on while someone is exercising on the exercise bike. The more you want to watch TV, the more you have to exercise.
  • Another way to set up this kind of system is to use a heart rate monitor. Here is an example of a simple DIY Infrared Pulse Sensor.

Step #11: Connecting the sensors to your Arduino
  • Most ways that you might set up your TV limiting system will require sensors of one kind or another, and these need to be connected to your Arduino. Connecting sensors to an Arduino is easy. There are two main kinds of inputs with an Arduino. There are analog inputs and there are digital inputs.
  • Analog inputs detect the relative voltage of a signal. To measure an analog input, connect the ground wire of the sensor to one of the GND pins on the Arduino. Then connect the signal wire to one of the analog input pins on the Arduino. Then set this pin to input mode and use the analogRead function in the Arduino code. The Arduino will then measure the voltage of the input signal and turn it into an integer value between 0 and 1023. This corresponds to a voltage between 0 and 5 volts. Analog inputs are a good way to monitor signals that change over time.
  • Digital inputs just detect whether a signal is above a certain threshold voltage (3 volts for a 5 volt Arduino). These are useful for detecting simple on-off states (i.e. whether the signal is there or not). To use this kind of input, connect the ground wire from the sensor to one of the GND pins on the Arduino. Connect the signal wire to one of the digital pins on the Arduino. Then set this pin to input mode and use the digitalRead function in the Arduino code. The Arduino will then measure the voltage of the input signal and register it as either HIGH (above 3 volts) or LOW (below 3 volts).

Step #12: Use your TV limiting system
  • Set up the box with the control circuit near your TV. Then plug one end of the cable into your TV and plug the other end into the signal source. I used an RCA cable to connect my XBOX 360 to the TV. Lastly, connect your chosen sensors that will control the system.
  • This system is an interesting way to cut back on the amount of TV that we consume. Use your imagination and have fun!