Jota Game

by RobBest in Circuits > Microcontrollers

904 Views, 3 Favorites, 0 Comments

Jota Game

Board_Front_With_IR.jpg

One of my colleagues works for the scouting in The Netherlands. Once every year they have an event where they want kids to play with electronics by purchasing a soldering kit. This colleague had a board from 2010 that he really liked with some LED patterns and some LED games but this board can no longer be purchased. So I suggested to make something like that board and add some other LED patterns and other games using a PIC Microcontroller, programmed with the JAL programming language.

Since I wanted the board to be reusable and that kids could learn some programming, I added a connector to the board to which a PICkit programmer can be connected. I also wrote an instruction on how to get started with reprogramming the board.

The board has eight user features and has a power down feature to save batteries. The eight user features are:

  1. Light house LED pattern
  2. Snake LED pattern
  3. Knight Rider LED pattern
  4. Simon Says game
  5. Jota Game
  6. Pong game
  7. Morse game
  8. Battleship game

A complete description of these game and more information can be found in the attached pdf. The power down mode is described in the section about the software.

Supplies

The requirement for this Jota Game board was that it should cost no more than 5 Euro. With the following components this is possible if purchased in larger quantities.

You need to have the following components for this project:

  • A piece of breadboard or the Jota Game Printed Circuit board
  • PIC microcontroller 16F18239 including 20-pin socket
  • 2 Omron switches
  • 6 * Red LEDs, 3 * Green LEDs, 2 * Yellow LEDs, 1 * Infra-red LED
  • 1 * 8.2 Ohm, 11 * 82 Ohm, 1 * 330 Ohm, 3 * 10k resistors
  • 1 * TSOP4838 Infra-red receiver
  • 1 * BC640 transistor
  • 2 * AAA battery holder
  • 1 * 6-pin female header

The Design

Schematic_Diagram.png

The heart is formed by a PIC16F1829 Microcontroller. I used this 20-pin version since I needed to have sufficient pins to control all external parts. The board is powered by two AAA batteries so it operates at 3 Volt. All LEDs have resistors in series to limit the maximum current to about 10 mA. The current through the infra-red LED is much higher, about 150 mA. Due to this high current a BC640 transistor is used that can handle a current of 1 Ampere.

Although the PIC can operate at 2 Volt, the infra-red receiver needs a minimum voltage of 2.5 Volt. So rechargeable batteries cannot be used unless the user does not play the infra-red games.

Switches are connected via pull-up resistors. One of these pins is also used by the programmer connection to reprogram the PIC if needed.

In order to save power, the infra-red receiver is powered via a pin of the PIC Microcontroller so that it is only activated when needed.

See the schematic diagram on how to connect the components.

Building the Electronics

Jota_Game_Infra_Red.png
pcb_layout.png
Board_Back.jpg

You can build the circuit on a breadboard or the printed circuit board. In the picture you find the layout of the printed circuit board.

Since the Jota Game board makes use of infra-red communication and players are often facing each other with the board towards them, it is recommended to solder the infra-red LED and infra-red receiver on the backside of the board. The picture show what that looks like.

Soldering all components on the printed circuit board takes about 1 hour.

The Software

Jota Game

As already mentioned, the software is written for a PIC16F1829. It was written in JAL. The software uses 5254 bytes of ROM and 159 bytes of RAM. There is plenty of room left to change games or make a new game since this PIC has 8k of ROM and 1k of RAM.

The software performs the following main tasks:

  • Course controlling all LED patterns and all LED games.
  • Handle the switches. Debouncing of the switches is done in software, no external components are used for debouncing.
  • Controlling timers. Three timers are used:
  • A timer for measuring the reaction time. This timer runs on a 1 ms timer tick.
  • A timer for generating the infra-red message. This timer runs on a 0.5 ms tick. The message uses a home brew format which is a combination of the Philips RC6 Remote Control protocol and the NEC Remote Control protocol.
  • A timer for generating a 38 kHz carrier for the infra-red signal.
  • Encoding and decoding the infra-red message. Both encoding and decoding are done on an interrupt basis. The external interrupt of the PIC is used for decoding.
  • Controlling the power of the infra-red receiver. During an infra-red transmission the infra-red receiver is switched off. It is only switched on when it expects an infra-red message so it is only activated during the games that use infra-red communication.
  • Power management. In order to save the batteries there is an auto-off feature. This works as follows:
  • When powered on a random LED pattern is shown. When no user activity is present for 1 minute, this LED pattern switches to a walking menu pattern.
  • When no user activity is present for 2 minutes, the walking menu pattern switches to a Lighthouse pattern in which one LED flashes shortly. The board then draws about 1.5 mA.
  • When no user activity is present for 3 minutes, the Light house pattern will put the PIC Microcontroller into sleep mode. In this mode hardly any current is used and the batteries are saved and do not have to be removed.
  • When a user stops playing a game but does not end the game, the Jota Game board would stay on. To prevent this, a watchdog is implemented in software. If there is no user activity for 5 minutes, the software will reset the PIC Microcontroller, which returns the PIC to the mode as if it was powered on. Using the previous power down features the PIC Microcontroller will be put to sleep after 6 minutes of inactivity.

The PIC controller runs on an internal clock with a frequency of 16 MHz, this because it cannot run at 32 MHz on 3 Volt. Next to that a higher clock also means a higher power consumption and this higher clock is not needed.

All source files and other documentation, including the printed circuit board design and Gerber file can be found on GitHub. If you are interested in using the PIC microcontroller with JAL – a Pascal like programming language – visit the JAL website.

For information on how to change the program of the Microcontroller for this project see the attached pdf.

The video shows the following:

  • A short demo of all features of the Jota Game Board.
  • The power down mode by starting with a Pong game and not end that game. After reset, walking menu and Light house, the PIC will be put to sleep.

Have fun building your own project and looking forward to your reactions.