IR library for Arduino Nano RP

Hello,
I have a project with Arduino Nano RP and need to use infrared receiver and transmitter,My issue is : all available libraries found does not for for Arm Cortex M0+ . Please any help ?

I am not sure what you are looking for. The code below takes codes from an IR receiver and sends them out an IR transmitter. It will display codes if you enable it. Its purpose was to receive one code from my TiVo remote (input) and output 7 skip codes. It is written for the Arduino IDE 1.8.13 and the Raspberry Pi Nano RP2040. This probably is not what your end product will look like but it is a good start. If it asks for a library not available in the IDE, it may be one I created. Drop a note and I will post it to you. I have not worked with this in over 2 years, memory???

/*
IR Relay Pico for TiVo
*/
//////////////////////////////////////////
// Send TiVo IR Remote Control Commands // Orange
// By B.B. Blake 3/25/2021 // *** COM8 ***
//////////////////////////////////////////

#include <TiVo_Remote_Keys.h> // get the HEX codes for the TiVo keys

//#include <TiVo_Remote.h> // Compiler not capable to compile
//#include <IRremote.h> // Compiler not capable to compile
//#define SEND_PWM_BY_TIMER;
//#define USE_NO_SEND_PWM;

// Usage format - TiVo_Remote(uint32_t TiVo_Command); // then 'send_IR_Command'
///////////////////////////////////////////////////
const uint32_t RCA_Volume_Up = 0xD02FFB04; //
const uint32_t RCA_Volume_Down = 0xC03FFB04; //
const uint32_t RCA_Input_Select = 0xF40BFB04; //
const uint32_t RCA_Mute = 0xF609FB04; //
///////////////////////////////////////////////////
const int IR_LED = 26; // IR Send Data
const int IR_Vcc = 1; // IR Power Pin
const int IR_Rxx = 2; // IR Receive Data Pin
const int LED_Red = 6;
const int LED_Blue = 7;
const int LED_Green = 8;
uint32_t TiVo_Command1 = 0x12345678;
uint32_t TiVo_Command2 = 0x12345678;
///////////////////////////////////////////////////
int Bad_Count = 0;
int count = 1;
int countx2 = 2;
uint16_t Array[100];
///////////////////////////////////////////////////
const uint32_t TiVo_String_Arrays = {TiVo_TiVo, TiVo_TiVo_Old, TiVo_Speech, TiVo_Green_Skip, TiVo_NETFLIX, TiVo_Swap, TiVo_Live_TV, TiVo_Info, TiVo_Zoom, TiVo_Exit, TiVo_Back,
TiVo_Up, TiVo_Right, TiVo_Down, TiVo_Left, TiVo_Select, TiVo_Guide, TiVo_Chan_Up, TiVo_Chan_Down, TiVo_Thumb_Up, TiVo_Thumb_Down, TiVo_Record, TiVo_Play,
TiVo_Rewind, TiVo_Pause, TiVo_Fast_Forward, TiVo_Slow_Motion, TiVo_Loop_Back_8Sec, TiVo_Skip_30Sec, TiVo_A_Yellow, TiVo_B_Blue, TiVo_C_Red, TiVo_D_Green_Skip,
TiVo_Num_1, TiVo_Num_2, TiVo_Num_3, TiVo_Num_4, TiVo_Num_5, TiVo_Num_6, TiVo_Num_7, TiVo_Num_8, TiVo_Num_9, TiVo_Num_0, TiVo_Clear, TiVo_Enter, TiVo_Last};

const String TiVo_Strings = {"TiVo_TiVo", "TiVo_TiVo_Old", "TiVo_Speech", "TiVo_Green_Skip", "TiVo_NETFLIX", "TiVo_Swap", "TiVo_Live_TV", "TiVo_Info", "TiVo_Zoom", "TiVo_Exit", "TiVo_Back",
"TiVo_Up", "TiVo_Right", "TiVo_Down", "TiVo_Left", "TiVo_Select", "TiVo_Guide", "TiVo_Chan_Up", "TiVo_Chan_Down", "TiVo_Thumb_Up", "TiVo_Thumb_Down", "TiVo_Record", "TiVo_Play",
"TiVo_Rewind", "TiVo_Pause", "TiVo_Fast_Forward", "TiVo_Slow_Motion", "TiVo_Loop_Back_8Sec", "TiVo_Skip_30Sec", "TiVo_A_Yellow", "TiVo_B_Blue", "TiVo_C_Red", "TiVo_D_Green_Skip",
"TiVo_Num_1", "TiVo_Num_2", "TiVo_Num_3", "TiVo_Num_4", "TiVo_Num_5", "TiVo_Num_6", "TiVo_Num_7", "TiVo_Num_8", "TiVo_Num_9", "TiVo_Num_0", "TiVo_Clear", "TiVo_Enter", "TiVo_Last" ,"Not TiVo"};

const String Cardinal_Strings = {"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve"};

// ()=No Translation () () () < > () v ^ OK 0 * # 1 2 3 4 5 6 7 8 9
uint32_t Silver[21] = {0xF30CFF00, 0xA15EFF00, 0xBD42FF00, 0xF708FF00, 0xA55AFF00, 0xB54AFF00, 0xAD52FF00, 0xE718FF00, 0xE31CFF00, 0xE619FF00, 0xE916FF00, 0xF20DFF00, 0xBA45FF00, 0xB946FF00, 0xB847FF00, 0xBB44FF00, 0xBF40FF00, 0xBC43FF00, 0xF807FF00, 0xEA15FF00, 0xF609FF00};
// CH- CH_ CH+ |<< >>| >|| - + EQ 0 100+ 200+ 1 2 3 4 5 6 7 8 9
uint32_t Black[21] = {0xBA45FF00, 0xB946FF00, 0xB847FF00, 0xBB44FF00, 0xBF40FF00, 0xBC43FF00, 0xF807FF00, 0xEA15FF00, 0xF609FF00, 0xE916FF00, 0xE619FF00, 0xF20DFF00, 0x0F3CFF00, 0xE718FF00, 0xA15EFF00, 0xF708FF00, 0xE31CFF00, 0xA55AFF00, 0xBD42FF00, 0xAD52FF00, 0xB54AFF00};
uint16_t SilverIR = false;

const uint32_t bitArray {0b00000000000000000000000000000001, 0b00000000000000000000000000000010, 0b00000000000000000000000000000100, 0b00000000000000000000000000001000,
0b00000000000000000000000000010000, 0b00000000000000000000000000100000, 0b00000000000000000000000001000000, 0b00000000000000000000000010000000,
0b00000000000000000000000100000000, 0b00000000000000000000001000000000, 0b00000000000000000000010000000000, 0b00000000000000000000100000000000,
0b00000000000000000001000000000000, 0b00000000000000000010000000000000, 0b00000000000000000100000000000000, 0b00000000000000001000000000000000,
0b00000000000000010000000000000000, 0b00000000000000100000000000000000, 0b00000000000001000000000000000000, 0b00000000000010000000000000000000,
0b00000000000100000000000000000000, 0b00000000001000000000000000000000, 0b00000000010000000000000000000000, 0b00000000100000000000000000000000,
0b00000001000000000000000000000000, 0b00000010000000000000000000000000, 0b00000100000000000000000000000000, 0b00001000000000000000000000000000,
0b00010000000000000000000000000000, 0b00100000000000000000000000000000, 0b01000000000000000000000000000000, 0b10000000000000000000000000000000};
////////////////////////////////////////////////
void IR_Start() { // Send 9000us of 38KHz burst to start Start transmission
for(int x = 0; x < 342; x++) { // 342 pulses of 38KHz burst
digitalWrite(IR_LED, HIGH);
delayMicroseconds(13); // 38KHz = 26.31578947us
digitalWrite(IR_LED, LOW);
delayMicroseconds(13); // 13us-high + 13us-low is approximatly 38KHz
}
}
//////////
void IR_Stop() {
IR_Mark();
delayMicroseconds(5000);
}
//////////
void IR_Mark() { // 560us of 38KHz burst to start Bit transmission
for(int x = 0; x < 20; x++) { // 20 pulses of 38KHz burst
digitalWrite(IR_LED, HIGH);
delayMicroseconds(13); // 38KHz = 26.31578947us
digitalWrite(IR_LED, LOW);
delayMicroseconds(13); // 13us-high + 13us-low is approximatly 38KHz
// a quiet time of 562us for a '0', or 1688us for a '1' required,
// end of transmission requires 5000us of quiet time
}
}
//////////
void IR_One() {
IR_Mark();
delayMicroseconds(1688);
}
//////////
void IR_Zero() {
IR_Mark();
delayMicroseconds(562);
}
//////////
void TiVo_Make_Array(uint32_t TiVo_Command) { // TiVo_Command is distroyed during the array build processes
// Create bit Array of Microsecond values to be transmitted using the 32 bit NEC format
// '1' == 530,1670, '0' == 530,620 (with offset of 20 for VS1838 receivers)
// Start with 9000, 4500, Stop with 530, 5000
Serial.print(" - 0x"); // Show command data being sent
Serial.println(TiVo_Command, HEX); //
Array[0] = 9000; // Data Start bit, prime the pump
Array[1] = 4500; // Data Start bit
for(count = 1; count < 33; count++) { // examine 32 bits, LSb first
int bit = TiVo_Command & 0x1; // Store LSb in 'bit'
TiVo_Command = TiVo_Command >> 1; // Dump LSb from Long Word shift off of Word end
countx2 = count + count; // Double bit pointer, two numbers per bit
Array[countx2] = 530; // Bit Start
if(bit) { // Test if LSb is '1' or'0'
Array[countx2 + 1] = 1670; // Bit is a '1'
} else {
Array[countx2 + 1] = 620; // Bit is a '0'
}
Array[countx2 + 2] = 530; // Stop bit High (first part)
}
if(false) { // Diagnostic output, if 'true' show Array
for(int x = 0; x < count2+1; x++) {
Serial.print(Array[x]);
Serial.print("-");
}
Serial.println("");
}
// Turn our Array over to the IRremote.h library to transmit the TiVo command via IR
send_IR_Command(TiVo_Command); // IrSender.sendRaw(Array, sizeof(Array)/ sizeof(Array[0]), NEC_KHZ);
delay(50); // 50ms Stop Low (second part)
}
void send_IR_Command(uint32_t TiVo_Command) { // TiVo_Make_Array must be called first
digitalWrite(LED_Blue, HIGH);
for(int y = 0; y < count
2+1; y++) { // Send datta array as IR Pulses ('i' is number of data blocks to be sent)
int z = (Array[y]);
switch(z) {
case 9000: IR_Start(); break;
case 4500: delayMicroseconds(4500); break;
case 530: IR_Mark(); break;
case 620: delayMicroseconds(562); break;
case 1670: delayMicroseconds(1688); break;
}
}
delay(50); // 50 milliseconds
digitalWrite(LED_Blue, LOW);
}
//////////
void skip_Send(int Num) {
digitalWrite(LED_Blue, HIGH);
for( int xx = Num; xx > 0; xx--) {
if(xx < 10) { Serial.print(" "); }
Serial.print(xx);
TiVo_Make_Array(TiVo_Skip_30Sec); // Create a data arrays from the String & send them
delay(750); // 750 milliseconds
}
digitalWrite(LED_Blue, LOW);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the setup function runs once when you press reset or power the board
void setup() {
#ifndef DISABLE_USB_SERIAL
// Enable serial port for reset/upload always
Serial.begin(115200);
delay(100); // wait for Serial to start
#endif
// initialize digital pin LED_BUILTIN as an output.
delay(3000);
Serial.println("Program START");
Serial.println(F("Sketch Location " FILE ", Compiled " DATE " at " TIME " Local"));
// IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // Start the receiver, enable feedback LED, take LED feedback pin from the internal boards definition
pinMode(LED_BUILTIN, OUTPUT);
pinMode(IR_LED, OUTPUT);
pinMode(IR_Rxx, INPUT_PULLUP); // Ground is on PCB Pin 3
pinMode(IR_Vcc, OUTPUT);
pinMode(LED_Red, OUTPUT);
pinMode(LED_Blue, OUTPUT);
pinMode(LED_Green, OUTPUT);
digitalWrite(IR_Vcc, HIGH);
digitalWrite(LED_Red, HIGH);
digitalWrite(LED_Blue, HIGH);
digitalWrite(LED_Green, HIGH);

Serial.print("LED_BUILTIN = ");
Serial.println(LED_BUILTIN);
Serial.print("IR Tx LED = ");
Serial.println(IR_LED);
Serial.print("IR Rx Vcc = ");
Serial.println(IR_Vcc);
Serial.print("IR Rx Data = ");
Serial.println(IR_Rxx);
Serial.print("Red LED = ");
Serial.println(LED_Red);
Serial.print("Blue LED = ");
Serial.println(LED_Blue);
Serial.print("Green LED = ");
Serial.println(LED_Green);
delay(1000);
digitalWrite(LED_Red, LOW);
digitalWrite(LED_Blue, LOW);
digitalWrite(LED_Green, LOW);
randomSeed(analogRead(IR_Rxx));
}
////////////////////////////////////////////////
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(167); // wait for 1/6 second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(167); // wait for 1/6 second
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(167); // wait for 1/6 second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for 1/2 second

digitalWrite(LED_Red, LOW);
digitalWrite(LED_Green, LOW);

while (!digitalRead(IR_Rxx)) { // Loop while Low/OFF
delayMicroseconds(13);
}
int bitCount = 0;
for(int x = 0; x < 34; x++) {

int n = micros();
while (!digitalRead(IR_Rxx)) { // Loop while High/On
  delayMicroseconds(13);
}
int nn = micros() - n;

// if(nn < 10000) {
// Serial.print(nn); Serial.print("-ON ");
// }

int f = micros();
while (digitalRead(IR_Rxx)) { // Loop while Low/OFF
  delayMicroseconds(13);
}
int ff = micros() - f;

// if(ff < 10000) {
// Serial.print(ff); Serial.print("-OFF ");
// }

if((10000 > nn and nn > 8000) and (5000 > ff and ff > 4000)) {

// Serial.println("Start | ");
TiVo_Command1 = 0b00000000000000000000000000000000;
bitCount = 0;
}

if((700 > nn and nn > 350) and (1700 > ff and ff > 1200)) {

// Serial.print("One | ");
TiVo_Command1 = (TiVo_Command1 | bitArray[bitCount]);
bitCount++;
// if(bitCount < 10) { Serial.print(" "); }
// Serial.print(bitCount);
// Serial.print(" 0x");
// Serial.println(TiVo_Command1, HEX);
}

if((700 > nn and nn > 350) and (700 > ff and ff > 400)) {

// Serial.print("Zero | ");
bitCount++;
// if(bitCount < 10) { Serial.print(" "); }
// Serial.print(bitCount);
// Serial.println(" ");
}
}
if(bitCount == 32) {
Serial.println("");
Serial.println("Good IR Code Capture");
digitalWrite(LED_Red, LOW);
digitalWrite(LED_Green, HIGH);
} else {
Serial.println("");
Serial.println("BAD IR Code Capture");
digitalWrite(LED_Red, HIGH);
digitalWrite(LED_Green, LOW);
}
if(SilverIR) { // Convert Black IR Codes to Silver IR Codes
for( int x = 0;x < 21; x++){
if(TiVo_Command1 == Black){ TiVo_Command1 = Silver; break; }
}
}
Serial.print("Command Received = 0x");
Serial.println(TiVo_Command1, HEX);
for (int y = 0; y < 46; y++) {
if (TiVo_Command1 == TiVo_String_Arrays[y])
Serial.println(TiVo_Strings[y]);
break;
}
digitalWrite(LED_Blue, HIGH);
switch(TiVo_Command1) {
case(RCA_Input_Select): { Serial.println("TiVo Input"); skip_Send(7); break; }
case(0xBA45FF00): { Serial.println("One 0:30 sec"); skip_Send(1); break; }
case(0xB946FF00): { Serial.println("Two 1:00 min"); skip_Send(2); break; }
case(0xB847FF00): { Serial.println("Three 1:30 m:s"); skip_Send(3); break; }
case(0xBB44FF00): { Serial.println("Four 2:00 min"); skip_Send(4); break; }
case(0xBF40FF00): { Serial.println("Five 2:30 m:s"); skip_Send(5); break; }
case(0xBC43FF00): { Serial.println("Six 3:00 min"); skip_Send(6); break; }
case(0xF807FF00): { Serial.println("Seven 3:30 m:s"); skip_Send(7); break; }
case(0xEA15FF00): { Serial.println("Eight 4:00 min"); skip_Send(8); break; }
case(0xF609FF00): { Serial.println("Nine 4:30 m:s"); skip_Send(9); break; }
case(0xE619FF00): { Serial.println("Ten 5:00 min"); skip_Send(10); break; }
case(0xA55AFF00): { Serial.println("TiVo Fast Forward"); TiVo_Make_Array(TiVo_Fast_Forward); break; }
case(0xF708FF00): { Serial.println("TiVo Rewind"); TiVo_Make_Array(TiVo_Rewind); break; }
case(0xE31CFF00): { Serial.println("TiVo Play"); TiVo_Make_Array(TiVo_Play); break; }
case(0xE916FF00): { Serial.println("TiVo Rewind 8 Seconds"); TiVo_Make_Array(TiVo_Loop_Back_8Sec); break; }
case(0xF20DFF00): { Serial.println("TiVo Skip Forward 30 Seconds"); TiVo_Make_Array(TiVo_Skip_30Sec); break; }
case(0xE718FF00): { Serial.println("TiVo Clear"); TiVo_Make_Array(TiVo_Clear); break; }
case(0xAD52FF00): { Serial.println("TiVo Enter/Last"); TiVo_Make_Array(TiVo_Enter); break; }
// Not Used Silver 0xF30CFF00, 0xA15EFF00, 0xBD42FF00, 0xB54AFF00
}
delay(750);
digitalWrite(LED_Blue, LOW);
}
////////////////////////////////////////

Hello Blakebr, thank for your reply , i will try to use your code and see if i can use it.

I am interrested by this command :TiVo_Command1 = (TiVo_Command1 | bitArray[bitCount]);