LCD Relay pin conflict

LCD Relay pin conflict

This relay shield 4 Channel 5V Relay Module Board Shield

I'm already using pins 7 to 12 for a 4x16 LCD.

The examples I’ve seen for using a relay use pins 6 7 8 9 – some of the same pins as LCD.
So I thought for the relay I could just use different pins, after a bit of experimentation I found I could use these pins
#define Relay1 7
#define Relay2 6
#define Relay3 5
#define Relay4 4

  • will not work with pins 3 2 1 0
    But as the LCD users pin 7 theres a conflict, even if I miss out pin seven on the relay set up the LCD set up is sending a signal to pin 7 that operates relay1

Any thoughts on what if anything I can do

Any thoughts on what if anything I can do

I don’t understand why the relay will not work on pins 3 and 2 (stay away from 0 and 1 because of serial).

But, the analog pins can be used as digital pins, referred to as A0, A1, etc.

For example LiquidCrystal lcd(12, 13, A1, A2, A3, A4);

Use different pins for the LCD and modify the constructor to match.

Don

I don't understand why the relay will not work on pins 3 and 2 (stay away from 0 and 1 because of serial).

I could find no documentation for the relay board at the link provided in the original post but the photo of the bottom of the pc board shows the relay hard wired to pins 4, 5, 6, and 7.

What is cleverly omitted on the link to the Arduino constructor description that I posted earlier is how to make good use of this information, so here it is.

Start out by assigning Arduino pins to the devices that require specific pins. In this case the relay board must use pins 4, 5, 6, and 7 because the designers of it's pc board were too lazy to provide for any flexibility. In other cases you may have to use specific pins to take advantage of PWM, timers, serial I/O etc.

When you are all done with those devices then use whatever pins are left over for your LCD. You can use any Arduino pin to drive any of the LCD data or control pins - just put the appropriate pin numbers into the constructor.

Don

What good and informative answers your all given people, not only a way to fix the problem but knowledge i didn't have.
I had wondered if i could use a different pin for the LCD. I tend to construct from examples 'monkey see monkey do' its when things dont work as expected and a answer has to be found that knowledge really bumps up. Its just bumped.
Tomorrow I'll move the connection from pin seven to the spare pin 13 and modify the constructor to match - or I could use other pins as shown by you informative people.

Thanks help much appreciated

I'll move the connection from pin seven to the spare pin 13 and modify the constructor to match

My recommendation would be to use pin A0, A1, A2, or A3 as the new pin.

Pin 13 has the on board led, and you might find it useful to use that in a sketch.

Digital 2 and 3 are external interrupt pins, and its good to keep them free. 0 and 1 are Serial RX/TX so leave them alone.

A4 and A5 are the i2c bus, and again its good to keep them free.