Self-Made Laser Tag

We all have played the laser tag game at various fest or amusement parks. This laser tag is suitable for two player but can be easily extended to more number of players. Another advantage of this system is that in place of conventional infrared light used in commercial system, real lasers are used. In simpler terms it comprises of a laser blaster, base station, and shot detection vest. Every blaster comprises of an RF transceiver, an LCD, a sensor, and a laser. The laser is used to fire at other players on the press of a button.

A RF transceiver is also used to send and receive any information about the game. Each blaster is also equipped with a photo-transistor to determine if the blaster itself has been hit by another player. An ATmega644 is used along with a self-made laser driving circuit to drive the laser. A real timer kernel is deployed on the MCU as it allow one to easily manage the main tasks and control how often to run them, as well as to provide certain tasks with a higher priority when needed. A fun project which can also be extended to long range by reducing the noise from the ambient light.

Use fixed integer types to enhance portability

If you have programmed anything with C you should be familiar with common data types like char, unsigned char, int, unsigned int, long int, long long int, etc. It is really hard to tell by looks of type how many bytes this variable takes on memory and how it looks in different system. For instance in 8-bit AVR-GCC compiler int is 16-bit type, while in ARM-GCC int is 32-bit. So int size is dependent on platform, compiler and runtime libraries. And switching between systems may trick you if you are not careful enough.


You can always check the size of variable by using sizeof() function. What to do if you need your code to be portable between different systems. Some great libraries could work on any system including 8-bit, 16-bit, 32-bit or 64-bit. In order avoid this annoying problem the ISO C99 standard introduced portable data types that are defined in stdint.h header file. If you open this header file of your default compiler tool-set you will find how things are organized. First of all it checks the length of int types and then defines portable types by using special naming format [u]intN_t. If number is for unsigned number you add u in front of type name and if do not add anything is unsigned. N indicates number of bits the variable will take. So this is simple table of common portable integer types: Continue reading

Using Volatile keyword in embedded code

Volatile is probably least documented keyword in most tutorials and books. Probably this is main cause of most misuses and bugs related to it. If you already are programming microcontrollers, you probably know that volatile is always used on global variables that are accessed from interrupt service routines. Otherwise code won’t work.


After few requests I decided to drop few lines about volatile keyword. This keyword is commonly used to tag memory type. We hear “volatile memory”, “non-volatile memory” when talking about computer hardware. As quick reminder – “non-volatile memory” is type of memory that stores its contents even when power is off. Such type of memory is EEPROM, Flash, FRAM. This is easy from hardware perspective. But what volatile keyword means in C or C++ code? This is an indicator (called qualifier) to compiler that tells that this variable may be changed during program flow even if it doesn’t look like to be. This means that compiler must treat this value seriously and keep optimizer away from it. Continue reading

Interfacing GPS Module with AVR

GPS modem is a device which receives signals from satellite and provides information about latitude, longitude, altitude, time etc. The GPS navigator is more famous in mobiles to track the road maps. The GPS modem has an antenna which receives the satellite signals and transfers them to the modem. The modem in turn converts the data into useful information and sends the output in serial RS232 logic level format. The information about latitude, longitude etc. is sent continuously and accompanied by an identifier string.


The connection of GPS modem with AVR microcontrollers shown in the circuit diagram. The ground pin of max 232 and serial o/p of GPS modem is made common. Pin2 of MAX232 is connected to pin 3 of GPS modem and pin 3 of max 232 is connected to pin 2 of modem. This type of connection is called a serial cross cable. Continue reading