Introduction: Kids Screen Timer With Arduino
This device gives a parent a really robust means of controlling the amount of screen-time (TV / DVD / console) their kids have each day. It works by having an intelligent time-switch which controls the HDMI signal passing between a device and the TV display. I found it works really well, because it completely ends any argument about when the TV is turned off. It's not possible to negotiate/plead/argue with a machine. Key features of the device are as follows:
0. 8-digit seven segment display to show time, system status, who's logged in and how much time is left
1. Any number of fully definable timeslots during a day / week / month etc. during which a child may watch TV
2. Individual RFID tags for each child which allows them to 'log in' during a time slot and watch TV
3. Daily TV minutes quota per child which ticks down on the display as they watch
4. Gradual accrual of TV minutes throughout the day (at a parent-selected rate and with an upper limit)
5. Timed override tag which allows viewing at any time, with 15 minutes added per swipe up to an arbitrary upper limit
6. Parental override tag which toggles TV operation on and off at any time without restrictions and allows access to other functions
7. Penalty deduction of minutes for individual children and negative balances if you need to ban tomorrow's TV
This project is a work in progress. It's been operational for around 14 months and has been getting more and more sophisticated over that time. I continue to refine it to meet my needs as a parent. It has worked really well for me and hasn't damaged my AV kit or my kids - nevertheless, if you build and use this device you do so at your own risk.
Ultimately I will box the system up to make it tamperproof and pleasing to the eye. Currently though, the kids are too young to figure out that they can bypass the control by fiddling with the HDMI leads; so the nice enclosure can wait. When they figure out how to hack the Arduino, I'll be delighted!
Apart from the RFID tags and display, this system has a largely non-existent user interface. All of the time slots and restrictions etc. are therefore programmed directly into the code. On the positive side, this gives the builder almost unlimited flexibility. Implementing a configuration menu is at the bottom of my priority list for this project, but if you are capable of assembling it from scratch you should have no problems tweaking the code to meet your specific needs.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Get Your Parts Together
You will need:
- Arduino (I used a nano, as they are really compact)
- Arduino-controlled HDMI switch (a hacked COTS part described in one of my other instructables)
- DS1307 RTC module
- MiFARE classic RFID reader module
- A selection of brightly coloured RFID tags - you'll need two plus the number of kids who need access
- Eight-digit seven segment LED display with single MAX72xx shift register
- Protoboard or stripboard depending on how robust you want the final build to be
- 2.54mm pitch stripboard screw-terminal blocks (4 way)
- Hook-up wires
- DC power socket and matching mains adaptor
Optionally, you may decide it's better to put the HDMI switching transistor onto the timer board rather than fitting it dead-bug style into the HDMI switcher unit - this cuts down on the number of wires and is probably neater. If so, you'll also need:
- 1kOhm resistor
- 2N2907 PNP transistor
All these parts came from ebay.co.uk.
You'll also need to import the following libraries for your arduino:
I gratefully acknowledge the efforts of the authors of these libraries that made this project possible, and also those who wrote the example code (particularly for the MiFARE RFID reader) which I have cut and shut into my sketch.
Step 2: Connect Up the Circuit
This bit is pretty easy but long-winded. Use appropriate hook-up wires to connect the Arduino to the peripheral modules in line with the following scheme. I've omitted the 0 V and 5 V / 3.3 V connections as I have assumed these are obvious. The photos show the layout I used on a piece of stripboard to realise this circuit. Note that I decided to put the HDMI switching transistor on the timer board (rather than inside the switch itself, as I described in my other instructable). That was because it's a bit neater and simpler to do.
HDMI switch (with local switching transistor)
Note - I have had excellent results with the rectangular one shown on this page and would recommend it.
- Nano pin D8 to HDMI switcher control line
HDMI switch (transistor on timer board as described in the remainder of this instructable)
- Nano pin D8 to base of 2N2907 via 1K resistor
- Collector of 2N2907 to +5V rail of HDMI switcher - don't forget to remove those three diodes!
- Emitter of 2N2907 to +5V rail of power supply
RFID module (3.3V)
- Nano pin D9 to RST
- Nano pin D10 to SS
- Nano pin D11 to MOSI
- Nano pin D12 to MISO
- Nano pin D13 to SCK
Be careful, as I have two RFID modules that look very similar but the header pins are in a different order on each.
DS1307 module (5V)
- Nano pin A4 to SDA
- Nano pin A5 to SCL
Seven segment display module (5V)
- Nano pin D5 to LOAD / CS
- Nano pin D6 to CLK
- Nano pin D7 to DATA IN
Touchpads (optional - not yet implemented in code)
- Nano pins A0 to A3 brought out via screw terminals to individual copper touchpads
Step 3: System Configuration
There are a number of things to do before you can use the system properly. When the all the modules (including the Nano) are fitted to the circuit-board, plug the Nano into your PC via the USB interface to power it up and start configuring things:
Set the real-time clock
The easiest way I've found to do this is to load and run the following sketch by WWC:
You can use the text-based user interface via the Arduino IDE serial monitor to set the clock.
Obtain four-byte IDs from all RFID tags to be used in system
Load the example sketch from http://playground.arduino.cc/Learning/MFRC522. Use the Arduino IDE serial monitor to display tag data.
Decide which tags will perform each function. Give your kids a tag of their favorite colour as it's easier for everyone to remember. Swipe each tag across the reader and write down its four-byte ID code (shown in hexadecimal). These IDs need to be assigned to user names & accounts via the user array in the sketch.
Install the timer sketch
Load the attached sketch into the Arduino.
This will need to be customised to your personal requirements, but the code is liberally commented so hopefully it will be self-explanatory. Drop me a comment if you need help.
Step 4: Personalising the Sketch
The sketch is fairly well commented in the areas that matter for configuration purposes. Here is a summary of the most important steps:
1. Populate the 'user' array with the RFID tag IDs and relevant usernames. It's possible to display most characters on a seven-segment array with a little imagination.
I've put together some hex values for what I consider to be reasonable representations of nearly all the letters of the alphabet (IMHO). Some letters need two characters or the decimal point. See if you can figure out a good 'V'.
A 0x77; a 0x7D; b 0x1F; C 0x4E; c 0x0D; d 0x3D; E 0x4F; e 0x75; F 0x47; G 0x5E; g 0xDB; H 0x37; h 0x17; i 0x10; I 0x30; J 0x3C; k 0x3F; L 0x0E; M 0x66 & 0x72; n 0x15; o 0x1D; P 0x67; q 0x73 (& decimal point); r 0x05; s 0x5B; t 0x0F; u 0x1C; v (don't know); W 0x1E & 0x6C; x 0x19 & 0x0D; y 0x41 and finally Z 0x6D.
Make sure the maxUsers is equal to the total number of users in the array. Note that the first two rows of the array are reserved for parent and timer tags respectively.
2. Programme the permitted viewing windows; this is done using a series of if statements which operate on the time of day expressed in minutes. This approach is extremely flexible, at the expense of being less user-friendly.
3. Programme the timer tag increment, daily minutes acrual rate & penalty minutes decrement. Alternatively, leave them as they are.
Step 5: Controlling the TV Timer
First and foremost, make sure that your TV only has HDMI signal inputs. This system won't fully block viewing if an antenna is still connected directly to the TV. Take out all the HDMI signal inputs (e.g. DVD, PVR, set-top box) and plug them instead into the HDMI switcher described earlier. Take the output of the switcher and plug it into HDMI 1 (or whatever) on your TV. Then select this as your TV's default AV input signal. You shouldn't need to change AV inputs again on the TV. Then power up the TV timer, which should display the current time in 24 hour format and either 'oFF' or 'tAG', depending whether user viewing is blocked or not.
The TV timer is controlled by swiping RFID tags across the reader. 'rFid' appears briefly on the display if a valid tag is detected.
A parent or timer tag can switch on the TV (i.e. enable HDMI) at any time. You will need to hide these tags from the kids for obvious reasons, but not so you forget where you put them...
When in parent mode, 'PArEnt' is displayed and the HDMI signal is enabled indefinitely until the parent tag is swiped again. Good for late-night films without interruptions. Going into parent mode also overrides any other function and is the only way to cancel the timer mode described below. If a user tag is swiped whilst in parent mode, a time penalty is applied to that user. This increases with additional swipes of the tag and can go negative (so a user could effectively lose tomorrow's TV). I don't use this much but it's there if you want it.
When in timer mode, the display shows 'XXX LEFt', where XXX is the time remaining in minutes. The first swipe gives 15 minutes of viewing; this is increased in 15 minute intervals by additional swipes of the timer tag, up to a pre-programmed 'limit' of 999 minutes! This is a good way of giving kids a bonus half-hour of TV without having to keep your eye on the clock. The time remaining display counts down until reaching zero, at which point the TV signal is disabled.
Any other tag is considered a 'user' tag (held by the kids).
If the timer says XX:XX oFF, (where XX:XX is the real time) no user can enable the TV
If the timer says XX:XX tAG, users can log on and off by swiping their RFID tag. The display will alternate every couple of seconds between their name and the number of minutes of viewing they have left, e.g. 'PEtEr' & '34 LEFf'. The time remaining display counts down until reaching zero, at which point the TV signal is disabled. If the real time goes outside of a permitted window, the TV signal will also be disabled and the user will be logged out, even if they still have minutes. Minutes are accrued over time up to a maximum (currently 120) and are not lost except by viewing or parent penalties.
If two or more HDMI sources are active at once, you can choose between them by pressing the channel select button on the HDMI switcher.
Step 6: An Evolving Concept That Grows With Your Kids!
One thing I discovered when writing this instructable was that the TV timer was never really 'finished'. I have been using it for just over a year and it has been really successful. For most of that time it was just a lash-up (shown), but it worked perfectly and as a time-poor parent, I didn't think that spending the time to make it look nice was worth the trouble. The strip-board version was motivated by my desire to publish my work on this device, so I had to tidy things up a bit. It is exactly the same circuit but was designed to be installed along with the switch in a plastic enclosure which prevents access to the HDMI cables. I haven't found the need to protect the cables from the kids yet.
The lack of user-friendly set-up interface also isn't a problem for me; any new circumstance that arises with the kids can usually be accommodated with a couple of extra lines of code. This system first started out as a simple timer which blocked access outside certain permitted windows (and even that was good); it's now evolved to give the kids far more control over how their time is used, whilst ultimately still keeping the parent in control.
I will of course try to update this instructable as I make substantial changes to the system over the coming months and years. Current to-dos are:
- Require a parent tag swipe after reboots - stops kids resetting their time allowance (when they inevitably figure out how)
- Use ADCtouch to allow up/down/select menu to facilitate setup and other items (listed below)
- Warning beeper when time is nearly up
- Time measurement in seconds rather than minutes - currently every time you log in, you lose a minute almost instantly.
- Menu only method of applying parental penalties; they don't like giving you their tags when they know what you have in mind...
- Arduino control of the channel-select switch on the switcher - if you have two sources running simultaneously, you need a means of changing channels; this is fine on the lash-up but if everything is inside a neat enclosure you won't be able to get to it except through the Arduino user interface.
- Install system in the plastic enclosure (goal is to drill no unnecessary holes - hence the use of the touch-pad concept)
Anyway, I hope you find this interesting and useful. Watch this space...
Runner Up in the
Digital Life 101 Challenge