I am trying to multiplex some seven segments(common cathode), and I want to write my own code. I am using functions in order to more easily change what the program is doing later on. The first simple function defines the pins used for the LED's and sets them as outputs (I would think). I did this so I could change these easily later on. I want to use the pin assignments in other parts of the code, but still define them as arguments in the multiplexPins function. Is there any way to do this? (In general, I need to know how to do the title of this thread.)
This is what I am using for the first function.
void multiplexPins(const int pinA, const int pinB, const int pinC, const int pinD, int pinE, const int pinF, const int pinG, const int blinkPin){
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(blinkPin, OUTPUT);
}
Keep in mind, I'm very new to arduino. Sorry if what I'm saying isn't exactly clear. Thanks ![]()
EDIT: I may have a solution, but I am not sure if it works. I added this to the code.
int pinA = 0;
int pinB = 0;
int pinC = 0;
int pinD = 0;
int pinE = 0;
int pinF = 0;
int pinG = 0;
int blinkPin = 3;
void multiplexPins(const int pinA, const int pinB, const int pinC, const int pinD, int pinE, const int pinF, const int pinG, const int blinkPin){
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(blinkPin, OUTPUT);
}