Arduino Bridge Clock

For a work related question, I recently had to look at microcontrollers. Microcontrollers are small computers that can be programmed to control all kinds of devices. To connect to those devices, they have digital and analog input/output channels allowing to measure something and then take action. For example, one can connect a temperature sensor to measure the temperature in the room, then have the program on the controller decide to switch the heating on. 

Microcontrollers usually have a wifi on board, or are connected to another chip providing that functionality, as well. That allows them to connect to the Internet, allowing them to exchange information with other devices. To continue the example above, this allows you run an app on your smartphone that allows you switch on the central heating while you are driving home. It can even go a step further, your smartphone has GPS in it, so it can switch on the heating by itself when you are driving in the direction of your house. 

While this may sound like science fiction, it is in fact reality. Smart electricity meters are being rolled out today, remote controlled thermostats are brought to the market by various vendor, and manufacturers are putting them in other apparatus as well. The price certainly isn’t an issue, they have dropped to the order 1€/piece (which is a little less than 1 US$) over the last years, which means that one can put one in a fridge or washing machine without making it noticeably more expensive.

Of course, there is a downside to all this as well. First of all, none of these devices specify what information they send to the outside world, who gets that information and how it is protected. These are private networks with closed protocols, which makes it hard to monitor. Just to give an example, it might be very convenient for me if the heating turns itself down automatically when I leave in the morning. But, if the same information can be tapped by a thief planning to break in, I’d not be happy about this. 

The second problem is that all these devices pose security risks. They are programmable, which means that they can be reprogrammed to do something bad. That can range from something innocent to serious hacking attempts.  There are more issues here, but they are outside the scope of this blog.

So, is there something bridge related here? 

Yes, there is. When I started to look into these issues, I got myself a few microcontrollers plus some additional hardware in order to test them and see what one can do with them. A popular kit is the Arduino. This is an open source hardware platform that one can use to experiment. The heart of the Arduino is a ATmega328P microcontroller, which is a very common and popular model. You can get startier kits with an Arduino, manual and introduction textbook, a CD with the software (though that is downloadable for free as well) and some bits and pieces of hardware to control for around €50. It takes a day or so to work through the examples but then you have a fairly good idea of what can be done with these devices. Programming these devices is actually quite easy, it can be done in C and all you need to provide are 2 functions, one to configure the board on startup and one to handle all inputs and outputs every second.

Most clubs use a timer to control the flow of the game. You know the device: a clock shows the time left in a round, sounds a buzzer 5 minutes or so before the end, and then again at the end of the round. They have a few buttons to start and stop them. 

As this is custom hardware with only a limited number of customers, they are expensive. A clock typically costs between €175 and €250.  

When programming the Arduino, I noticed that it had an internal clock running in microsecond steps. The clock isn’t calibrated, but for bridgegames with timescales of 7.5 minutes a board, this is sufficient resolution. My starter kit seemed to contain one needs for a  bridgetimer: display, buzzer, pushbuttons. So, can we build one. 

On the right, you see my attempt. This is on a prototyping board, more about that later. The Arduino (top right) is connected to 5 pushbuttons on pins 2 through 6, a buzzer (pin 7) and a 2x16 character display (pins 8 to 13).  I have the full wiring diagram on request. There is a LED next to each button, this is for debugging, in a final product it can be removed. The whole thing is powered with a standard USB power supply. 

Writing the software took the better part of an afternoon, the code is downloadable here. The documentation is in the code for now.  As this is software, the clock has a few additional features:

  • During setup, one can enter the number of rounds to be played. During play the current round is shown. 
  • When the game is over, the time starts to count the time elapsed after the grace period. Thus, if a table is late, a peek at the clock shows you how much time extra time was used. 
  • During play, the clock can be paused if the game is interrupted for one reason or another. It is also possible to add or substract time to the clock, for example if all tables are late, you can add a few minutes to the clock. If all tables are ready earlier, you can shorten the current round.

The clock now works, but as this is on a prototyping board, this is not ready for daily use.

Hardwarewise, this clock contains about €30 of hardware, but this can be halved if you use an Arduino clone. Instead of a prototyping board, it would be nice if the components were soldered on a board, those boards can be produced for a few €. Boxes to house them are on the market for a few € as well. Finally, it’d be nice if the display is a little bigger and the buzzer a bit louder. I know both exist but my knowledge of electronics is too limited to pick the right one. All in all, I estimate that these can be produced for something of the order of €30 to €50.

Which brings up a question: is there anybody out there interested to work with me and see if we can turn this into a marketable product. Contact me of you are


© Henk Uijterwaal 2019