Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am doing the IR Remote and Display Project. I need to add these functions to t

ID: 1766212 • Letter: I

Question

I am doing the IR Remote and Display Project. I need to add these functions to the Arduino code below. I already have the code from 0-9 listed below but you only need to do is to add these 4 functions to the code:

1- When I press (Fast Forward) on the remote, show “A” on the display.

2- When I press (Fast Reverse)on the remote, show “C” on the display

3- When I press (-) on the remote, show “F” on the display

4- When I press (+) on the remote, show “E” on the display

Here is the code:

#include "IRremote.h"

/*-----( Declare Constants )-----*/

int receiver = 13; // pin 1 of IR receiver to Arduino digital pin 10

/*-----( Declare objects )-----*/

const int latchPin = 8;

const int clockPin = 12;

const int dataPin = 11;

IRrecv irrecv(receiver);           // create instance of 'irrecv'

decode_results results;            // create instance of 'decode_results'

/*-----( Declare Variables )-----*/

unsigned char lookup_7seg[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x80};

void setup()   /*----( SETUP: RUNS ONCE )----*/

{

pinMode(latchPin, OUTPUT);

pinMode(clockPin, OUTPUT);

pinMode(dataPin, OUTPUT);

Serial.begin(9600);

Serial.println("IR Receiver Raw Data + Button Decode Test");

irrecv.enableIRIn(); // Start the receiver

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/

{

if (irrecv.decode(&results)) // have we received an IR signal?

{

     Serial.println(results.value, HEX); // UN Comment to see raw values

    translateIR();

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

}

}/* --(end main loop )-- */

// displays the dice number on the 7-seg display

void DiceNumber(unsigned char num)

{

    digitalWrite(latchPin, LOW);

    shiftOut(dataPin, clockPin, MSBFIRST, lookup_7seg[num]);

    digitalWrite(latchPin, HIGH);

    delay(1000);

    

    

   digitalWrite(latchPin, LOW);

   shiftOut(dataPin, clockPin, MSBFIRST, lookup_7seg[10]);

   digitalWrite(latchPin, HIGH);

    delay(50);

   

}

/*-----( Declare User-written Functions )-----*/

void translateIR() // takes action based on IR code received

{

switch(results.value)

{

   case 0xFF02FD:

    Serial.println(" >>   Fast Forward(A)           ");

   

A;

   

    break;

case 0xFF30CF:

    Serial.println(" 1              ");

   DiceNumber(1);

   

   

    

    break;

case 0xFF18E7:

    Serial.println(" 2              ");

    DiceNumber(2);

       

   

    break;

case 0xFF7A85:

    Serial.println(" 3              ");

DiceNumber(3);

   

   

   

   

    break;

case 0xFF10EF:

    Serial.println(" 4              ");

    DiceNumber(4);

   

     

   

   

   

    break;

case 0xFF38C7:

    Serial.println(" 5              ");

   DiceNumber(5);

   

   

   

   

   

    break;

case 0xFF5AA5:

    Serial.println(" 6              ");

    DiceNumber(6);

    break;

case 0xFF42BD:

    Serial.println(" 7              ");

    DiceNumber(7);

    break;

case 0xFF4AB5:

    Serial.println(" 8              ");

    DiceNumber(8);

    break;

case 0xFF52AD:

    Serial.println(" 9              ");

    DiceNumber(9);

    break;

default:

    Serial.println(" other button   ");

}

} //END translateIR

/* ( THE END ) */

Explanation / Answer

I donot know the type of LCD that you're using but I guess its a serial 16X2 characters LCD display that accepts ASCII characters. With this assumption I have added the required lines of code. Just make sure to replace 0x000001 , 0x000002 and 0x000003 in the switch statement with the IR decoded values for buttons fast reverse, - and + respectively. The code follows from the next line.

#include "IRremote.h"

/*-----( Declare Constants )-----*/

int receiver = 13; // pin 1 of IR receiver to Arduino digital pin 10

/*-----( Declare objects )-----*/

const int latchPin = 8;

const int clockPin = 12;

const int dataPin = 11;

IRrecv irrecv(receiver); // create instance of 'irrecv'

decode_results results; // create instance of 'decode_results'

/*-----( Declare Variables )-----*/

unsigned char lookup_7seg[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x80};

void setup() /*----( SETUP: RUNS ONCE )----*/

{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
Serial.begin(9600);
Serial.println("IR Receiver Raw Data + Button Decode Test");
irrecv.enableIRIn(); // Start the receiver
}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/

{
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX); // UN Comment to see raw values
translateIR();
irrecv.resume(); // receive the next value
}
}/* --(end main loop )-- */

// displays the dice number on the 7-seg display

void DiceNumber(unsigned char num)

{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, lookup_7seg[num]);
digitalWrite(latchPin, HIGH);
delay(1000);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, lookup_7seg[10]);
digitalWrite(latchPin, HIGH);
delay(50);
}

/*-----( Declare User-written Functions )-----*/

void translateIR() // takes action based on IR code received

{

switch (results.value)

{
case 0xFF02FD:

Serial.println(" >> Fast Forward(A) ");
digitalWrite(latchPin, LOW);
delay(5);
shiftOut(dataPin, clockPin, MSBFIRST, 'A');
digitalWrite(latchPin, HIGH);
delay(5);
break;

case 0x000001:

Serial.println(" >> Fast Reverse(C) ");
digitalWrite(latchPin, LOW);
delay(5);
shiftOut(dataPin, clockPin, MSBFIRST, 'C');
digitalWrite(latchPin, HIGH);
delay(5);
break;

case 0x000002:

Serial.println(" >> -(F) ");
digitalWrite(latchPin, LOW);
delay(5);
shiftOut(dataPin, clockPin, MSBFIRST, 'F');
digitalWrite(latchPin, HIGH);
delay(5);
break;

case 0x000003:

Serial.println(" >> +(E) ");
digitalWrite(latchPin, LOW);
delay(5);
shiftOut(dataPin, clockPin, MSBFIRST, 'E');
digitalWrite(latchPin, HIGH);
delay(5);
break;

case 0xFF30CF:

Serial.println(" 1 ");
DiceNumber(1);
break;

case 0xFF18E7:
Serial.println(" 2 ");
DiceNumber(2);
break;

case 0xFF7A85:
Serial.println(" 3 ");
DiceNumber(3);
break;

case 0xFF10EF:
Serial.println(" 4 ");
DiceNumber(4);
break;

case 0xFF38C7:
Serial.println(" 5 ");
DiceNumber(5);
break;

case 0xFF5AA5:
Serial.println(" 6 ");
DiceNumber(6);
break;

case 0xFF42BD:
Serial.println(" 7 ");
DiceNumber(7);
break;

case 0xFF4AB5:
Serial.println(" 8 ");
DiceNumber(8);
break;

case 0xFF52AD:
Serial.println(" 9 ");
DiceNumber(9);
break;

default:
Serial.println(" other button ");
}

} //END translateIR

/* ( THE END ) */

/*If it does not work let me know your problem in the comments and I'll try my level best to help you. All the best. :) */