Is there any way to use a function call instead of a pin number?
Suppose I want to use the LiquidCrystal library. To use it I have to declare which pins will be used: "LiquidCrystal (rs, enable, d4, d5, d6, d7)". How can I assign "abcd ();" instead of the usual int which will be the pin number?
I could work around it by bridging two pins and set one of them as rs and the other as digitalRead. In this case, the library would set the pin state to high and at this point the second pin could read this state and run the function, but I'm looking for a more elegant solution.
I am not clear exactly what you want to do and why. Please give an example of how the LiquidCrystal constructor would look if you could do what you want ?
Maybe I'm thinking wrong. I am trying to repair a board whose microcontroller has broken, and they have not been producing them for several years. The manufacturer of the device ran out of pins, so he started multiplexing them. In order to physically activate the RS pin, it is necessary to set the appropriate high and low states on several outputs. Only then you can try to run the rs pin. To do it the easiest way, I decided to use a function after which I will set the appropriate states and finally the state of the rs pin.
Judging by your reaction, I am doing something wrong, so how do I do it?
Maybe someone has some other idea.
the lcd data pins could be reconfigured (i.e. input/output) in between LCD accesses for other purposes as long as their configuration is restored before the next LCD access.
for example, the same data pins could be used for a 2nd LCD as long as the LCD enable pins are unique
@thorourd, if you absolutely must initialize the LCD at runtime, then use dynamic allocation as I suggested way back in Post #2. Something like this:
#include <LiquidCrystal.h>
LiquidCrystal *displayPtr;
void setup() {
// do stuff here to set up rs pin at run time
displayPtr = new LiquidCrystal(rs, enable, d4, d5, d6, d7);
}
void loop() {
}