IR Sensor & 7 Segment Display Initial Testing

As part of the prototype for laser tag project, I’ve put together a Universal IR Infrared Receiver TL1838 VS1838B working in conjunction with a 4 digit 7 segment display I brought from Aliexpress. I am working towards building a testing platform to something similar to the schematic I’ve drawn below.

We decided to go with a 4 digit display for flexibility in game programming. Mostly likely, the first two digits will be used for health and the last two will be used for ammo. The three IR Sensors on the bottom with their respective LEDs will eventually be attached on to a vest and linked back up to the gun. The IR sensors were tested with the Arduino Nano and the IR detector library from Ken Shirriff’s Blog. It was successful in detecting my remote control from a distance of more than 10 meters away. The testing code for the IR sensor and the 7 segment display is shown below.
#include <IRremote.h>
int RECV_PIN = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;
int x = 1;
void setup()
{
irrecv.enableIRIn(); // Start the receiver
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(14, OUTPUT);
pinMode(15, OUTPUT);
pinMode(16, OUTPUT);
pinMode(17, OUTPUT);
pinMode(18, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(12, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(14, LOW);
digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
delay(250);
}
void loop() {
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
delay(x);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
delay(x);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(x);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(x);
if (irrecv.decode(&results)) {
irrecv.resume(); // Receive the next value
digitalWrite(13, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
}else{
digitalWrite(13, LOW);
}
}
The hardware setup of the 7 segment display was a bit complicated because I couldn’t find the specifications for the pins. I had to test each individual segment myself. If anybody is having trouble figuring out where the common anode is, you can refer to my spread sheet here.
Like this:
Like Loading...