
Problem Identification
Infrared remote controls come with almost every household device, such as televisions, fans, home theatre systems, etc., which, over time, clutter a living space. A cluttered living space is more of a problem for persons who are disabled.
Objective
The objective is to design a conceptual universal infrared remote that can control a few devices to minimise clutter.
Design
The following schematic details the hardware setup.
Table 1 lists the components used in the schematic.
ID | Component | Manufacturer Part No. | Value | Qty. |
Base Components | ||||
IC1 | MCU | PIC24FJ256GA702-I/SP | – | 1 |
IC2 | Regulator | LM1117T-3.3/NOPB | 3.3V / 800mA | 1 |
C1 & C2 | Capacitor (tantalum) | TAP106K025SRW | 10uF / 25V | 2 |
C3 & C4 | Capacitor (ceramic) | SR155C103KARTR1 | 0.01uF / 50V | 2 |
C5 & C6 | Capacitor (ceramic) | SR155C104KARTR1 | 0.1uF / 50V | 2 |
C7 & C8 | Capacitor (ceramic) | SR151A150JARTR1 | 15pF / 100V | 2 |
C9 | Capacitor (ceramic) | FG16X7R1E106KRT06 | 10uF / 25V | 1 |
Y1 | Crystal | ABL-16.000MHZ-B2 | 16MHz | 1 |
R1 | Resistor | SFR2500001002FR500 | 10kΩ | 1 |
R2 | Resistor | SFR2500001004FR500 | 1MΩ | 1 |
J1 | Header (6-way) (PICkit 5) | 22-27-2061 | – | 1 |
Additional Components | ||||
R3 – R10 | Resistor | SFR2500001002FR500 | 10kΩ | 8 |
R11 | Resistor | SFR2500001050FR500 | 105Ω | 1 |
C10 – C12 | Capacitor (ceramic) | SR155C104KARTR1 | 0.1uF / 50V | 3 |
D1 | LED (infrared) | WP710A10F3C | 20mA | 1 |
S1 – S3 | Switch (tactile) | FSM4JART | – | 3 |
J2 | Header (7-way) (Keypad (3×4)) | 22-27-2071 | – | 1 |
IC3 | OLED | SSD1306 | – | 1 |
Refer to the following source code. Lines #74 and #75 call the SSD1306.h and Keypad.h libraries, respectively. The Infrared_Codes.h library is called within the Keypad.h library. Note that the Keypad.h library has been modified to suit this project, as shown in the second block of code. The Infrared_Codes.h library is shown in the third block of code.
/* Universal_Remote (source code) */
/* MCU: PIC24FJ256GA702 */
/* Author: Michael */
/**************************** Configuration Bits ******************************/
// FSEC
#pragma config BWRP = OFF // Boot Segment Write-Protect bit (Boot Segment may be written)
#pragma config BSS = DISABLED // Boot Segment Code-Protect Level bits (No Protection (other than BWRP))
#pragma config BSEN = OFF // Boot Segment Control bit (No Boot Segment)
#pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written)
#pragma config GSS = DISABLED // General Segment Code-Protect Level bits (No Protection (other than GWRP))
#pragma config CWRP = OFF // Configuration Segment Write-Protect bit (Configuration Segment may be written)
#pragma config CSS = DISABLED // Configuration Segment Code-Protect Level bits (No Protection (other than CWRP))
#pragma config AIVTDIS = OFF // Alternate Interrupt Vector Table bit (Disabled AIVT)
// FBSLIM
#pragma config BSLIM = 0x1FFF // Boot Segment Flash Page Address Limit bits (Enter Hexadecimal value)
// FOSCSEL
#pragma config FNOSC = PRIPLL // Oscillator Source Selection (Primary Oscillator with PLL module (XT + PLL, HS + PLL, EC + PLL))
#pragma config PLLMODE = PLL96DIV4 // PLL Mode Selection (96 MHz PLL. Oscillator input is divided by 4 (16 MHz input))
#pragma config IESO = OFF // Two-speed Oscillator Start-up Enable bit (Start up with user-selected oscillator source)
// FOSC
#pragma config POSCMD = HS // Primary Oscillator Mode Select bits (HS Crystal Oscillator Mode)
#pragma config OSCIOFCN = ON // OSC2 Pin Function bit (OSC2 is general purpose digital I/O pin)
#pragma config SOSCSEL = OFF // SOSC Power Selection Configuration bits (Digital (SCLKI) mode)
#pragma config PLLSS = PLL_PRI // PLL Secondary Selection Configuration bit (PLL is fed by the Primary oscillator)
#pragma config IOL1WAY = OFF // Peripheral pin select configuration bit (Allow multiple reconfigurations)
#pragma config FCKSM = CSDCMD // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled)
// FWDT
#pragma config WDTPS = PS1 // Watchdog Timer Postscaler bits (1:1)
#pragma config FWPSA = PR32 // Watchdog Timer Prescaler bit (1:32)
#pragma config FWDTEN = OFF // Watchdog Timer Enable bits (WDT and SWDTEN disabled)
#pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode)
#pragma config WDTWIN = WIN50 // Watchdog Timer Window Select bits (WDT Window is 50% of WDT period)
#pragma config WDTCMX = WDTCLK // WDT MUX Source Select bits (WDT clock source is determined by the WDTCLK Configuration bits)
#pragma config WDTCLK = SYSCLK // WDT Clock Source Select bits (WDT uses system clock when active, LPRC while in Sleep mode)
// FPOR
#pragma config BOREN = OFF // Brown Out Enable bit (Brown Out Disabled)
#pragma config LPCFG = OFF // Low power regulator control (No Retention Sleep)
#pragma config DNVPEN = DISABLE // Downside Voltage Protection Enable bit (Downside protection disabled when BOR is inactive)
// FICD
#pragma config ICS = PGD1 // ICD Communication Channel Select bits (Communicate on PGEC1 and PGED1)
#pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)
// FDEVOPT1
#pragma config ALTCMPI = DISABLE // Alternate Comparator Input Enable bit (C1INC, C2INC, and C3INC are on their standard pin locations)
#pragma config TMPRPIN = OFF // Tamper Pin Enable bit (TMPRN pin function is disabled)
#pragma config SOSCHP = ON // SOSC High Power Enable bit (valid only when SOSCSEL = 1 (Enable SOSC high power mode (default))
#pragma config ALTI2C1 = ALTI2CEN // Alternate I2C pin Location (SDA1 and SCL1 on RB9 and RB8)
/************************* Configuration Bits (end) ***************************/
#define FCY 16000000 // FCY = FOSC / 2 (FCY: Instruction clock cycle) (FOSC: System clock cycle)
#define Button_Menu PORTAbits.RA0 // Button_Menu associated with MCU Pin #2
#define Button_Cursor PORTAbits.RA1 // Button_Cursor associated with MCU Pin #3
#define Button_Select PORTBbits.RB2 // Button_Select associated with MCU Pin #6
#define Keypad_C1 PORTBbits.RB13 // Keypad Pin #3 (Column #1) associated with MCU Pin #24
#define Keypad_C2 PORTBbits.RB15 // Keypad Pin #1 (Column #2) associated with MCU Pin #26
#define Keypad_C3 PORTBbits.RB11 // Keypad Pin #5 (Column #3) associated with MCU Pin #22
#define Keypad_R1 LATBbits.LATB14 // Keypad Pin #2 (Row #1) associated with MCU Pin #25
#define Keypad_R2 LATBbits.LATB7 // Keypad Pin #7 (Row #2) associated with MCU Pin #16
#define Keypad_R3 LATBbits.LATB10 // Keypad Pin #6 (Row #3) associated with MCU Pin #21
#define Keypad_R4 LATBbits.LATB12 // Keypad Pin #4 (Row #4) associated with MCU Pin #23
#define IR_LED LATBbits.LATB6 // IR_LED associated with MCU Pin #15
#include <libpic30.h> // Delay functions
#include <xc.h> // MCU pin mapping
#include "SSD1306.h" // OLED Display: Solomon Systech SSD1306
#include "Keypad.h" // Keypad: 3 x 4
int main(void)
{
// Set pin direction
TRISAbits.TRISA0 = 1; // MCU Pin #2 input (Button_Menu)
TRISAbits.TRISA1 = 1; // MCU Pin #3 input (Button_Cursor)
TRISBbits.TRISB2 = 1; // MCU Pin #6 input (Button_Select)
TRISBbits.TRISB13 = 1; // MCU Pin #24 input (Keypad Pin #3)
TRISBbits.TRISB15 = 1; // MCU Pin #26 input (Keypad Pin #1)
TRISBbits.TRISB11 = 1; // MCU Pin #22 input (Keypad Pin #5)
TRISBbits.TRISB14 = 0; // MCU Pin #25 output (Keypad Pin #2)
TRISBbits.TRISB7 = 0; // MCU Pin #16 output (Keypad Pin #7)
TRISBbits.TRISB10 = 0; // MCU Pin #21 output (Keypad Pin #6)
TRISBbits.TRISB12 = 0; // MCU Pin #23 output (Keypad Pin #4)
TRISBbits.TRISB6 = 0; // MCU Pin #15 output (IR_LED)
TRISBbits.TRISB8 = 1; // MCU Pin #17 input (I2C1 SCL1)
TRISBbits.TRISB9 = 1; // MCU Pin #18 input (I2C1 SDA1)
/************************* configure MCU modules **************************/
// Analog Ports
ANSA = 0; // Disable A (PIC24FJ256GA702 datasheet p.126 Table 11-1)
ANSB = 0;
// Comparators
CM1CONbits.CEN = 0; // Disable #1 (PIC24FJ256GA702 datasheet p.310 Register 25-1)
CM2CONbits.CEN = 0;
CM3CONbits.CEN = 0;
// ADC
AD1CON1bits.ADON = 0; // Disable module (PIC24FJ256GA702 datasheet p.291 Register 24-1)
// I2C1
I2C1BRG = 78; // Baud rate reload value (PIC24FJ256GA702 datasheet p.221 Eqn.18-1)
I2C1CONLbits.I2CEN = 1; // Enable module (PIC24FJ256GA702 datasheet p.222 Register 18-1)
I2C1CONLbits.DISSLW = 1; // Slew rate control disabled for standard speed mode (100kHz)
__delay_ms(100); // Delay to allow setup of I2C1
/********************** configure MCU modules (end) ***********************/
OLED_Setup(); // Set operating conditions for SSD1306
OLED_Clear(); // Clear display RAM (GDDRAM) of SSD1306
__delay_ms(100); // Delay to allow setup of SSD1306
uint8_t Screen_No = 0; // Screen number (Menu(0), Television(1), Lighting(2), Fan(3))
uint8_t Item_No = 0; // Item number within each screen
OLED_String(1,6,"Menu");
OLED_String(3,1,">Television"); // Cursor (>) is set to Television by default
OLED_String(5,1," Lighting");
OLED_String(7,1," Fan");
while(1)
{
/******************************** Menu ********************************/
if (Button_Menu == 0 && Screen_No != 0) // Screen #0 (Menu)
{
Screen_No = 0;
Item_No = 0; // Item #0 (Television)
OLED_Clear();
OLED_String(1,6,"Menu");
OLED_String(3,1,">Television");
OLED_String(5,1," Lighting");
OLED_String(7,1," Fan");
while (Button_Menu == 0); // Wait until switch Button_Menu opened
}
if (Button_Cursor == 0 && Screen_No == 0)
{
Item_No ++; // Scroll through items
if (Item_No == 1)
{
OLED_String(3,1," Television");
OLED_String(5,1,">Lighting");
OLED_String(7,1," Fan");
}
if (Item_No == 2)
{
OLED_String(3,1," Television");
OLED_String(5,1," Lighting");
OLED_String(7,1,">Fan");
}
if (Item_No == 3)
{
Item_No = 0;
OLED_String(3,1,">Television");
OLED_String(5,1," Lighting");
OLED_String(7,1," Fan");
}
while (Button_Cursor == 0);
}
/***************************** Menu (end) *****************************/
/**************************** Television ******************************/
if (Button_Select == 0 && Screen_No == 0 && Item_No == 0) // Screen #1 (Television)
{
Screen_No = 1;
OLED_Clear();
OLED_String(1,1,"Television");
OLED_String(3,1,"Use keypad");
OLED_String(4,1,"to change chnl.");
OLED_String(6,1,"*: Volume down");
OLED_String(7,1,"#: Volume up");
while (Button_Select == 0);
}
if (Screen_No == 1)
{
Keypad_TV(); // Execute Keypad (TV)
}
/************************* Television (end) ***************************/
/***************************** Lighting *******************************/
if (Button_Select == 0 && Screen_No == 0 && Item_No == 1) // Screen #2 (Lighting)
{
Screen_No = 2;
Item_No = 0;
OLED_Clear();
OLED_String(1,1,"Lighting");
OLED_String(3,1,"1: ON");
OLED_String(4,1,"3: OFF");
OLED_String(6,1,"4: Red");
OLED_String(7,1,"5: Green");
OLED_String(8,1,"6: Blue");
while (Button_Select == 0);
}
if (Screen_No == 2)
{
Keypad_Lighting(); // Execute Keypad (Lighting)
}
/************************** Lighting (end) ****************************/
/******************************* Fan **********************************/
if (Button_Select == 0 && Screen_No == 0 && Item_No == 2) // Screen #3 (Fan)
{
Screen_No = 3;
OLED_Clear();
OLED_String(1,1,"Fan");
OLED_String(3,1,"1: ON");
OLED_String(5,1,"2: OFF");
while (Button_Select == 0);
}
if (Screen_No == 3)
{
Keypad_Fan(); // Execute Keypad (Fan)
}
/**************************** Fan (end) *******************************/
}
return 0;
}
/* Keypad: 3 x 4 (library) */
/* Filename: Keypad.h */
/* Author: Michael */
#include "Infrared_Codes.h" // Infrared codes
/****************************** Television **********************************/
uint8_t Digit_Pos = 0; // Digit position (LHS|RHS)
char Keychar;
char Keystr[1];
void Keypad_TV(void)
{
Keypad_R1 = 1; // Set Keypad Row #1 as HIGH
Keypad_R2 = 0; // Set Keypad Row #2 as LOW
Keypad_R3 = 0;
Keypad_R4 = 0;
if (Keypad_C1 == 1) // If first column of Keypad (C1) reads HIGH
{
Keychar = '1';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","00100000"); // Transmit TV signal (Key #1)
while (Keypad_C1 == 1); // Wait for Key #1 to be released
}
else if (Keypad_C2 == 1)
{
Keychar = '2';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","10100000"); // Transmit TV signal (Key #2)
while (Keypad_C2 == 1);
}
else if (Keypad_C3 == 1)
{
Keychar = '3';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","01100000"); // Transmit TV signal (Key #3)
while (Keypad_C3 == 1);
}
else
{
Keypad_R1 = 0;
Keypad_R2 = 1;
Keypad_R3 = 0;
Keypad_R4 = 0;
if (Keypad_C1 == 1)
{
Keychar = '4';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","00010000"); // Transmit TV signal (Key #4)
while (Keypad_C1 == 1);
}
else if (Keypad_C2 == 1)
{
Keychar = '5';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","10010000"); // Transmit TV signal (Key #5)
while (Keypad_C2 == 1);
}
else if (Keypad_C3 == 1)
{
Keychar = '6';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","01010000"); // Transmit TV signal (Key #6)
while (Keypad_C3 == 1);
}
else
{
Keypad_R1 = 0;
Keypad_R2 = 0;
Keypad_R3 = 1;
Keypad_R4 = 0;
if (Keypad_C1 == 1)
{
Keychar = '7';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","00110000"); // Transmit TV signal (Key #7)
while (Keypad_C1 == 1);
}
else if (Keypad_C2 == 1)
{
Keychar = '8';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","10110000"); // Transmit TV signal (Key #8)
while (Keypad_C2 == 1);
}
else if (Keypad_C3 == 1)
{
Keychar = '9';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","01110000"); // Transmit TV signal (Key #9)
while (Keypad_C3 == 1);
}
else
{
Keypad_R1 = 0;
Keypad_R2 = 0;
Keypad_R3 = 0;
Keypad_R4 = 1;
__delay_ms(100);
if (Keypad_C1 == 1)
{
Keychar = '*';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","11010000"); // Transmit TV signal volume-down (Key *)
while (Keypad_C1 == 1);
}
if (Keypad_C2 == 1)
{
Keychar = '0';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","10001000"); // Transmit TV signal (Key #0)
while (Keypad_C2 == 1);
}
else if (Keypad_C3 == 1)
{
Keychar = '#';
Keystr[0] = Keychar;
Digit_Pos++;
IR_Transmit_TV("11100000","11100000"); // Transmit TV signal volume-up (Key #)
while (Keypad_C3 == 1);
}
}
}
}
if (Digit_Pos == 3)
{
Digit_Pos = 1; // Reset back to LHS digit position
}
OLED_String(3,Digit_Pos + 5,Keystr);
}
/**************************** Television (end) ********************************/
/******************************** Lighting ************************************/
void Keypad_Lighting(void)
{
Keypad_R1 = 1;
Keypad_R2 = 0;
Keypad_R3 = 0;
Keypad_R4 = 0;
if (Keypad_C1 == 1)
{
Keychar = '1';
Keystr[0] = Keychar;
IR_Transmit_Lighting("00000001","01111000"); // Transmit lighting signal ON (Key #1)
while (Keypad_C1 == 1);
}
else if (Keypad_C3 == 1)
{
Keychar = '3';
Keystr[0] = Keychar;
IR_Transmit_Lighting("00000001","01001000"); // Transmit lighting signal OFF (Key #3)
while (Keypad_C3 == 1);
}
else
{
Keypad_R1 = 0;
Keypad_R2 = 1;
Keypad_R3 = 0;
Keypad_R4 = 0;
if (Keypad_C1 == 1)
{
Keychar = '4';
Keystr[0] = Keychar;
IR_Transmit_Lighting("00000001","10000000"); // Transmit lighting signal Red (Key #4)
while (Keypad_C1 == 1);
}
else if (Keypad_C2 == 1)
{
Keychar = '5';
Keystr[0] = Keychar;
IR_Transmit_Lighting("00000001","01000000"); // Transmit lighting signal Green (Key #5)
while (Keypad_C2 == 1);
}
else if (Keypad_C3 == 1)
{
Keychar = '6';
Keystr[0] = Keychar;
IR_Transmit_Lighting("00000001","11000000"); // Transmit lighting signal Blue (Key #6)
while (Keypad_C3 == 1);
}
}
}
/***************************** Lighting (end) *********************************/
/********************************** Fan ***************************************/
void Keypad_Fan(void)
{
Keypad_R1 = 1;
Keypad_R2 = 0;
Keypad_R3 = 0;
Keypad_R4 = 0;
if (Keypad_C1 == 1)
{
Keychar = '1';
Keystr[0] = Keychar;
IR_Transmit_Fan("00110011","00111010"); // Fan ON (Key #1)
while (Keypad_C1 == 1);
}
else if (Keypad_C3 == 1)
{
Keychar = '3';
Keystr[0] = Keychar;
IR_Transmit_Fan("00110011","11010010"); // Fan OFF (Key #3)
while (Keypad_C3 == 1);
}
}
/******************************* Fan (end) ************************************/
/* Infrared_Codes (library) */
/* Filename: Infrared_Codes.h */
/* Author: Michael */
void Carrier(void) // Function to generate standard carrier frequency (38kHz)
{
IR_LED = 1;
__delay_us(13);
IR_LED = 0;
__delay_us(13);
}
/******************************* Television ***********************************/
void Signal_1_TV(void) // Transmit signal HIGH (1)
{
for (int i = 0; i < 21; i ++) // HIGH period (550µs) 21 cycles of carrier wave
{
Carrier();
}
IR_LED = 0;
__delay_us(1710); // LOW period (1710µs)
}
void Signal_0_TV(void) // Transmit signal LOW (0)
{
for (int i = 0; i < 21; i ++)
{
Carrier();
}
IR_LED = 0;
__delay_us(550);
}
void IR_Transmit_TV(char Address[], char Command[]) // TV transmit (Samsung protocol)
{
/* Leading Edge */
for (int i = 0; i < 171; i ++) // HIGH period (4500µs) 171 cycles of carrier wave
{
Carrier();
}
IR_LED = 0;
__delay_us(4500);
/* Leading Edge (end) */
/* Address */
for (int j = 0; j < 2; j ++) // Transmit Address twice
{
for (int i = 0; i < 8; i ++) // Cycling through Address character array
{
if (Address[i] == '0')
{
Signal_0_TV();
}
else if (Address[i] == '1')
{
Signal_1_TV();
}
}
}
/* Address (end) */
/* Command */
for (int i = 0; i < 8; i ++) // Transmit Command
{
if (Command[i] == '0')
{
Signal_0_TV();
}
else if (Command[i] == '1')
{
Signal_1_TV();
}
}
for (int i = 0; i < 8; i ++) // Transmit Command (inverse)
{
if (Command[i] == '0')
{
Signal_1_TV();
}
else if (Command[i] == '1')
{
Signal_0_TV();
}
}
Signal_0_TV(); // End
/* Command (end) */
}
/**************************** Television (end) ********************************/
/******************************** Lighting ************************************/
void Signal_1_Lighting(void)
{
for (int i = 0; i < 21; i ++)
{
Carrier();
}
IR_LED = 0;
__delay_us(1710);
}
void Signal_0_Lighting(void)
{
for (int i = 0; i < 21; i ++)
{
Carrier();
}
IR_LED = 0;
__delay_us(550);
}
void IR_Transmit_Lighting(char Address[], char Command[]) // Lighting transmit
{
/* Leading Edge */
for (int i = 0; i < 346; i ++) // HIGH period (9000µs) 346 cycles of carrier wave
{
Carrier();
}
IR_LED = 0;
__delay_us(4500);
/* Leading Edge (end) */
/* Address */
for (int i = 0; i < 8; i ++) // Transmit Address
{
if (Address[i] == '0')
{
Signal_0_Lighting();
}
else if (Address[i] == '1')
{
Signal_1_Lighting();
}
}
for (int i = 0; i < 8; i ++) // Transmit Address (inverse)
{
if (Address[i] == '0')
{
Signal_1_Lighting();
}
else if (Address[i] == '1')
{
Signal_0_Lighting();
}
}
/* Address (end) */
/* Command */
for (int i = 0; i < 8; i ++) // Transmit Command
{
if (Command[i] == '0')
{
Signal_0_Lighting();
}
else if (Command[i] == '1')
{
Signal_1_Lighting();
}
}
for (int i = 0; i < 8; i ++) // Transmit Command (inverse)
{
if (Command[i] == '0')
{
Signal_1_Lighting();
}
else if (Command[i] == '1')
{
Signal_0_Lighting();
}
}
Signal_0_Lighting(); // End
/* Command (end) */
}
/***************************** Lighting (end) *********************************/
/*********************************** Fan **************************************/
void Signal_1_Fan(void)
{
for (int i = 0; i < 73; i ++) // HIGH period (1900µs) 73 cycles of carrier wave
{
Carrier();
}
IR_LED = 0;
__delay_us(640);
}
void Signal_0_Fan(void)
{
for (int i = 0; i < 24; i ++) // HIGH period (640µs) 24 cycles of carrier wave
{
Carrier();
}
IR_LED = 0;
__delay_us(1900);
}
void IR_Transmit_Fan(char Address[], char Command[]) // Lighting transmit
{
/* Address */
for (int i = 0; i < 8; i ++) // Transmit Address
{
if (Address[i] == '0')
{
Signal_0_Fan();
}
else if (Address[i] == '1')
{
Signal_1_Fan();
}
}
/* Address (end) */
/* Command */
for (int j = 0; j < 2; j ++) // Transmit Command twice
{
for (int i = 0; i < 8; i ++) // Cycling through Command character array
{
if (Command[i] == '0')
{
Signal_0_Fan();
}
else if (Command[i] == '1')
{
Signal_1_Fan();
}
}
}
Signal_0_Fan(); // End
/* Command (end) */
}
/******************************** Fan (end) ***********************************/
The following list describes how each of the functions, in the Infrared_Codes.h library, work:
- Carrier, line #5, generates the 38kHz IR carrier wave.
- Signal_1_TV, line #15, transmits signal 1 to a television.
- Signal_0_TV, line #28, transmits signal 0 to a television.
- IR_Transmit_TV, line #41, transmits commands to a television with a particular address.
- Signal_1_Lighting, line #122, transmits signal 1 to a light.
- Signal_0_Lighting, line #135, transmits signal 0 to a light.
- IR_Transmit_Lighting, line #148, transmits commands to a light with a particular address.
- Signal_1_Fan, line #239, transmits signal 1 to a fan.
- Signal_0_Fan, line #252, transmits signal 0 to a fan.
- IR_Transmit_Fan, line #267, transmits commands to a fan with a particular address.
The input devices for this remote are three tactical push-button switches and a 3×4 matrix keypad. The output devices for this remote are an IR LED, D1, and an OLED display, J2. Switch S1, when pressed, returns the OLED display to the main menu. Switch S2, when pressed, selects through a list of items. Switch S3, when pressed, activates a selected item. Follow the prompts on a selected item to execute certain functions. These switches are debounced by a capacitor, especially for S2 to minimise items being skipped on the OLED display.
Testing
Pressing the cursor button allows an item to be selected by the select button. Point the IR LED towards a device to be controlled and press the appropriate key on the keypad to send a unique code to achieve a specific result.
Conclusion
The code can be expanded and/or modified to include other devices.