DataBullets – Test IR Circuits

I love the idea of people interacting with information in the real world. I’d love to mess with the spacing of those audible line markings on the highway, so that if you run over it at a certain speed you’d head music, or something like that. For this project, I imagine a gun that fires little bullets of information, that the user inputs. In short, I had an idea for a custom laser tag system, and it goes something like this:

  • The players would have a certain number of Ammo Slots on their laser taggers, this number may start smaller and increase as they level up, or just be fixed for different games.
  • The players would have a range of different ammunition, and a limited number of each type of ammo. This might be based on a set allocation for the game, each player having equal ammo, or maybe they can buy different types of ammo, each unit being worth a different amount.
  • The players’ guns would have an LCD screen and a rotary encoder dial. On the screen, a series of characters would represent the type of ammo loaded into the gun. For example, a player may have 4 slots on their gun. This means that they can load up to 4 types of ammo for each shot. They may have standard ammo (say 10 damage points), heavy ammo (doubles the damage of the shot), poison ammo, healing ammo (for friends), rapid fire ammo (speeds up reload time), etc, etc. They could select a combination of this ammunition, which would be used when they pull the trigger. I’ve put a fair bit of thought, about 10 seconds or so, into the different types of ammo that could be used, but won’t go into it here.
  • The players could also customise their taggers to add things like a Favourites button to cycle through favourite shots, or a series of Favourites buttons.
  • Because the guns are to be custom built, there are also options for adjusting the optics of the system. e.g. a well aligned lens and LED would give a long range tagger, whereas an LED that’s slightly forward of the focal point would give a Shotgun tagger (less range, but wider beam), etc. Again, many possibilities here.

Since I am just fiddling with the electronics at this point, I thought I’d build a test system and incorporate it into my robot. I’m just going with a fairly basic implementation of the system, using arduino because it’s what I’m used to (I know there are other, better suited platforms out there, but the robot is running on arduino, and I don’t have time to learn another hardware system right now). This system will send basic Data Bullets without any feedback to the tagger when the robot is hit, and without any Shooter data in the bullet. The results of a hit will be determined by the data in the bullet, and will probably be along the lines of freezing the robot, shutting it down altogether, or making it freak out, etc.

I used Ken Shirriff’s IR Library for arduino, which seems to be one of the most notable such libraries out there, and certainly a lot easier than writting a protocol from scratch. Below are links to his website, showing examples of basic send/receive circuits and code, as well as a link to the library on Github

Ken Shirriff’s site, regarding IR for arduino:

Ken’s IR Library (download and #include in your arduino project) on Github:

Due to limitations with the arduino boards, and the IR libraries available online, only one LED Receiver input can be used at a time. Because of this, I bought a 4 input AND gate, and connected the signals from 4 different IR receivers to it (since they are Active Low, when one of them receives a bit the signal will go Low, dropping the output of the AND gate to Low, thus combining the signals). As you can see from the pictures below and the code at the end of this post, I’ve added an LCD display which shows the data received as Hexidecimal values (32 Bits = 4 bytes long = 8 Hex values). I won’t include a schematic, because it isn’t a particularly tricky circuit, but if anyone reads this and thinks “that is a very messy breadboard, I’d like a schematic”, leave a comment and I’ll sketch one up.

Receiver Pic 1

Receiver Pic 2

Remember, this is just a test, on a step to bigger and better things (maybe). Now that I know the system works, I’ll integrate it into my robot’s code and post an update later.

The Tagger test circuit is fairly simple. I just set a string of data that I wanted to send within the code (this would be adjusted on the run by the user, once I have built the tagger, complete with LCD screen). The Base pin of a transistor is connected to pin 3 (which the IR library uses for driving the LED); Using a transistor to drive the actual LED means that I can add more or run them at higher current without damaging the Arduino. The code is set up to send the signal whenever I connect +5v to the trigger input pin (through a SPST switch). Make sure you use a pull down resistor on your trigger input pin, to avoid misfires. Note: in the test circuit below, I didn’t bother wiring up a switch, I just used the orange jumper wire to connect to the +5v rail.

Tagger pic 1

Tagger pic 2

BOM (Bill of materials) – Receiver:

4 x IR receivers – TSOP4838

1 x dual 4 input AND gate – cd74hc21e

1 x potentiometer (for LCD contrast, model not particularly important)

1 x LCD screen – standard 16×2 compatible with the Hitachi HD44780 driver.

BOM – Tagger:

1 x IR LED – TSAL 6100 (940nm wavelength, 10° angle of half intensity, 100mA forward current)

1x resistor (for switch down)- 10kOhm or 100kOhm, not hugely critical

1x resistor (for limiting LED current)- 50 Ohm (can vary depending on your IR LED current rating, remember that the LED pulses, so you can go above the continuous current rating if you want a higher power blaster)

1 x Transistor – NPN transistor or N channel mosfet, you could use a BC337.

Notes on components

IR LED – you need an LED suitable for high pulse currents (so that you can get a stronger signal output). You also want a narrow “angle of half intensity”, which is basically the angle that the beam (out of the tip of the LED) diverges; a lower angle means that your beam will be narrower, thus going further before it’s too weak to be detected by the receiver. You also need to ensure that the output wavelength is suitable for your receiver (there’s a sensitivity graph on the receiver datasheets, so it doesn’t have to be an exact match, but an exact match will mean that your beam can be detected from a longer distance).

IR Receiver -I chose one with a 38MHz carrier frequency, which works okay with the protocols available in the IR library. These have an Active Low output (basically, it reads the signal represented by the carrier signal, and outputs a Low signal when the carrier signal is on)

AND gate – At first I wasn’t sure if the AND gate idea would work, until I actually looked at the inner workings of the CMOS AND gates… When the input signal bit length is more than 10 microseconds, a propagation time of 9 ns is negligible. Look up the part I used, it’s pretty cheap and easy to use.

Transistor -NPN transistor or N channel mosfet, not hugely important what spec, as the current that it’s controlling is relatively small. I used a 2N5494 because it was laying around (hugely oversized). If you want to know more about using a transitor to drive a load, there are some great websites out there. handy for using Arduino to drive large motors, LED arrays, etc. Normally you’ll just want to drive your transistors On/Off, so MOSFETs are very easy to use, efficient, and powerful:

Code Used – Receiver

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8,9,10,11,12,13);

#include <IRremote.h>
int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“hello, world!”);

irrecv.enableIRIn(); // Start the receiver

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
// lcd.print(millis()/1000);

if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);

irrecv.resume(); // Receive the next value


Code Used – Tagger

* IRremote: IRsendDemo – demonstrates sending IR codes with IRsend
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff

#include <IRremote.h>

IRsend irsend;

int buttonPin = 10;
int ledPin=13;
char signal;
unsigned long hecks;
String digit;

void setup()



void loop() {

if (digitalRead(buttonPin)==HIGH) {


for (int i = 0; i < 1; i++) {
irsend.sendNEC(0xAB34EF78, 32); //




One thought on “DataBullets – Test IR Circuits

  1. Pingback: Databullets #2 – A.R.M.S Pistol Mk. 1 – or: Something for Poland | Tesla and I

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s