How to Control 7 Segment Display with IR Remote using Arduino

Introduction

Controlling a 7-segment display using an infrared (IR) remote and an Arduino can be a fun and engaging project, offering a hands-on way to display numbers on the segment using an external remote control. This How to Control 7 Segment Display with IR Remote using Arduino project allows you to use an IR remote to trigger specific functions on an Arduino, which in turn illuminates particular segments of a 7-segment display to represent numbers from 0 to 9.

Hardware Required

Please Buy the following Hardware Components From Amazon for How to Control 7 Segment Display with IR Remote using Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Link
7-Segment Display1Buy Now
Remote with IR Receiver Module1Buy Now
Resistors 1KΩ2Buy Link
9v DC Adapter (Optional)1Buy Link
Jumper WiresFewBuy Link
Breadboard1Buy Link

Project Overview

The project involves using an IR remote to send signals to the IR receiver module connected to the Arduino. When the Arduino receives an IR signal, it triggers specific functions in the code that control the illumination of the 7-segment display to showcase numbers.

Code Functionality

The provided code utilizes the IRremote library to interpret signals received by the IR receiver module. It is structured to respond to specific IR codes corresponding to the buttons on the remote. Each button press triggers a particular function that controls which segments of the 7-segment display light up, representing numbers from 0 to 9.

Code Breakdown

  • The code begins by initializing the IR receiver module and setting up pin configurations for the 7-segment display.
  • It defines functions for displaying each digit (from 0 to 9) on the 7-segment display using specific combinations of lit segments.
  • There’s a function to turn off all segments of the display.
  • The loop() continuously checks for IR signals. Upon receiving a signal, it triggers the relevant function to display the corresponding number on the 7-segment display.
  • Additional conditions in the code handle turning on and off specific numbers displayed on the 7-segment based on the received IR signal.

Circuit Diagram

How-to-Control-7-Segment-Display-with-IR-Remote-using-Arduino-Circuit

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Installing Libraries

Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow

Code

//For more Projects: www.arduinocircuit.com

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;


void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);

pinMode(A1, OUTPUT);

}
int i0 = 0;
int i1 = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
int i5 = 0;
int i6 = 0;
int i7 = 0;
int i8 = 0;
int i9 = 0;

void loop() {
  if (irrecv.decode(&results)) {
  //  Serial.println(results.value, HEX);
  //  Serial.println(results.value);
    irrecv.resume(); // Receive the next value
    
    //button 1
    if(i1 == 0 && results.value == 16724175) 
    {
      Boff();
      Aone();
      //Serial.println("one on");
      i1 = 1;
      i0 = 0;

      i2 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i1 == 1 && results.value == 16724175)
    {
      Boff();
      //Serial.println("one off");
      i1 = 0;
    }
    //button 2
     else if(i2 == 0 && results.value == 16718055)
    {
      Boff();
      Atwo();
      i2 = 1;
      i0 = 0;
      i1 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i2 == 1 && results.value == 16718055)
    {
      Boff();
      i2 = 0;
    }
    //button 3
    else if(i3 == 0 && results.value == 16743045)
    {
      Boff();
      Athree();
      i3 = 1;
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i3 == 1 && results.value == 16743045)
    {
      Boff();
      i3 = 0;
    }
    //button 4
    else if(i4 == 0 && results.value == 16716015)
    {
      Boff();
      Afour();
      i4 = 1;
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i4 == 1 && results.value == 16716015)
    {
      Boff();
      i4 = 0;
    }
    //button 5
    else if(i5 == 0 && results.value == 16726215)
    {
      Boff();
      Afive();
      i5 = 1;
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i4 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i5 == 1 && results.value == 16726215)
    {
      Boff();
      i5 = 0;
    }
        //button 6
    else if(i6 == 0 && results.value == 16734885)
    {
      Boff();
      Asix();
      i6 = 1;
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i6 == 1 && results.value == 16734885)
    {
      Boff();
      i6 = 0;
    }
        //button 7
    else if(i7 == 0 && results.value == 16728765)
    {
      Boff();
      Aseven();
      i7 = 1;
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i7 == 1 && results.value == 16728765)
    {
      Boff();
      i7 = 0;
    }
        //button 8
    else if(i8 == 0 && results.value == 16730805)
    {
      Boff();
      Aeight();
      i8 = 1;
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i9 = 0;
    }
    else if(i8 == 1 && results.value == 16730805)
    {
      Boff();
      i8 = 0;
    }
        //button 9
    else if(i9 == 0 && results.value == 16732845)
    {
      Boff();
      Anine();
      i9 = 1;
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
    }
    else if(i9 == 1 && results.value == 16732845)
    {
      Boff();
      i9 = 0;
    }
        //button 0
    else if(i0 == 0 && results.value == 16738455)
    {
      Boff();
      Anort();
      i0 = 1;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }
    else if(i0 == 1 && results.value == 16738455)
    {
      Boff();
      i0 = 0;
    }
        //button power
    else if(results.value == 16753245)
    {
      Boff();
      i0 = 0;
      i1 = 0;
      i2 = 0;
      i3 = 0;
      i4 = 0;
      i5 = 0;
      i6 = 0;
      i7 = 0;
      i8 = 0;
      i9 = 0;
    }

    
  }
}


void Anort()
{
  digitalWrite(2, HIGH);
  digitalWrite(A1, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(3, HIGH);
}

void Aone()
{
   digitalWrite(A1, HIGH);
   digitalWrite(7, HIGH);
}

void Atwo()
{
    digitalWrite(2, HIGH);
    digitalWrite(A1, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
}

void Athree()
{
  digitalWrite(2,HIGH);
  digitalWrite(A1,HIGH);
  digitalWrite(4,HIGH);
  digitalWrite(7,HIGH);
  digitalWrite(6,HIGH);
}

void Afour()
{
 digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(7,HIGH);
}

void Afive()
{
 digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(7,HIGH);
digitalWrite(6,HIGH);

}

void Asix()
{
 digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(7,HIGH);
digitalWrite(6,HIGH);
digitalWrite(5,HIGH);
}

void Aseven()
{
 digitalWrite(2,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(7,HIGH);
}

void Aeight()
{
 digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(5,HIGH);
digitalWrite(7,HIGH);
digitalWrite(6,HIGH);
}

void Anine()
{
 digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(A1,HIGH);
digitalWrite(7,HIGH);
}
void Boff()
{
 digitalWrite(2, LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(A1,LOW);
digitalWrite(5,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
}

Further Steps:

To use this code effectively, ensure that the connections between the Arduino, the IR receiver, and the 7-segment display are properly set up. Also, make sure that the IR remote control emits signals compatible with the expected values in the code to function as intended.

Should you have any specific questions or encounter issues while working on this project, feel free to ask for additional assistance or clarification!

Applications

  1. Home Automation Convenience: Enables remote control and display for home devices using an IR remote and a 7-segment display with Arduino.
  2. Educational Demonstration: Offers an interactive educational tool to showcase the integration of IR remotes, 7-segment displays, and Arduino for learning basic electronics and coding.
  3. Numeric Information Displays: Provides a simple numeric display system suitable for small information kiosks or counters using an IR remote and a 7-segment display.
  4. Remote Signaling Systems: Utilizes an IR remote-controlled 7-segment display for remote indication or signaling in specific industrial or informative settings.
  5. Interactive Game and Puzzle Interfaces: Creates engaging interactive experiences or challenges using the 7-segment display controlled by an IR remote, suitable for gaming or escape room scenarios.

Leave a Comment


error: