Programmatically control connectivity between digital pin and device

I am working on a universal IR remote project that uses a 2.4" TFT screen, Arduino Uno, and an IR LED. The limitation is the IRremote library that only allows for 2 pins (D3 [timer 2] and D9 [timer 1]) on the Arduino to transmit IR signals. Unfortunately, both these pins are in use by the TFT screen.

I have found that if I disable connectivity of the IR LED when the screen is drawing/refreshing and connect it when i need to send a signal, they both work fine. The issue is I don’t want to have to have a manual/physical means to connect the IR LED when it’s time to send.

I was wondering if there’s a way I could use one of the digital I/O pins on the Arduino Uno not occupied by the TFT screen (D10 - 13 are free when SD card is not in use) to control connectivity of the IR LED pin (occupied by the TFT). That way I could just programmatically turn on the pin when I’m ready to send IR, and turn off that pin after sending.

I was able to mimic this concept up using a momentary switch to temporarily connect the IR LED when it’s ready to send. It works perfect, but if I can control that using an I/O pin, that that would streamline the physical design.

I also tried to manipulate the LiquidCrystal library to use different digital pins in an attempt to free up either pin 3 or pin 9 for use the IR send, but was unsuccessful.

Example:

// Init LCD
// Draw and fill LCD items
// Listen for touch
// Detect touch for sending IR commands
// Enable IR connectivity by controlling another pin connected in circuit to IR LED
// Send IR code
// Disable IR connectivity
// Resume TFT drawing/filling/refreshing

Any help is greatly appreciated! Thanks.

I also tried to manipulate the LiquidCrystal library to use different digital pins

Which library is this and which Arduino board ?

UKHeliBob:
Which library is this and which Arduino board ?

I’m using an Arduino Uno and the library is LiquidCrystal V1.2.1. I believe it’s modified from the original liquid crystal library to work with the cheap chinese variants, which is what I’m using.

Edit: I see now it’s using the SPFD5408 Library GitHub - JoaoLopesF/SPFD5408: Adafruit Libraries changed to works in TFT 2.4 shields with the SPFD5408 controller for Arduino Uno and Mega (Discontinued library)
which came from the project page I followed Arduino Touch Screen Calculator Project with Code

Here’s the website from the board, http://mcufriend.com/index.php?main_page=index&cPath=4 - I used it to get the library and follow the calculator project they had as a demo.

Please post an example program that uses the library and explain exactly which display you are using as there are several on the page that you linked to

I have posted an example that I modified from the calculator project as a working template for the graphics of my universal IR remote project. Please see attached.

For the screens, I bought these screens - 2.4 Inch TFT LCD Shield Socket Touch Panel Module 2.4" for Arduino UNO R3 | eBay

On the screen itself, it says:
http://www.mcufriend.com
tftlcd for arduino uno (spiflash)

arduino_tft_example.txt (4.74 KB)

I've attached an image of the TFT screen I'm using, the Arduino, and a theoretical configuration of what I'm trying to accomplish.

Please know I have little understanding of the underlying hardware, I/O, etc on the Arduino. I am an amateur when it comes to the Arduino but have some programming background.

20191124_133223[1].jpg

There seems to be some issues with your pin definitions:-

/*______Define LCD pins (I have asigned the default values)_______*/
#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
/*_______End of defanitions______*/

The touch screen YP seems to be sharing A1 with the LCD_WR pin on the display and XM is sharing A2 with LCD_CD.

Neither the touchscreen nor the LCD seem to be using digital pins 3 and 9.

Could you please supply some code that illustrates your problem?

Ian

I have attached an example project when I press the “P” button (Power) on the TFT, it will IR send the power on code for my TV. Both IR send and the TFT work separately. They only will work together if I connect a momentary switch between the IR LED and D3. If the IR LED remains connected when the TFT starts up, the display draws garbage and is basically non-functional. It’s only when I cut off D3 while the TFT draws and refreshes and only press the switch when I’m ready to send the IR (on button press) does it work.

As far as the pin occupancy, I found the following table at Arduino Touch Screen Calculator Project with Code which shows D3 as part of the LCD data pins. Also, I found this article https://forum.arduino.cc/index.php?topic=587737.0 which talks about what pins are free.

I’ve tried connecting to pin 3 and pin 9 while the TFT is on and it doesn’t work. Both cause the display to show garbage until I kill the connection to the IR LED.

Thank you all for your replies. I appreciate it!

arduino_tft_IRsend_example.txt (4.83 KB)

I was able to resolve my issue by simply connecting ground of the IR LED to a digital pin and keeping it HIGH until I'm ready to send an IR signal, then set LOW send the signal, and return it to HIGH afterwards. It's working perfectly! No issues with TFT.