0

Im driving a 7-segment display using Arduino and want to display some letters. I passed the index of array -> digitPins (which has stored the ports connected to Arduino) in the digital write function but it doesn't work. However, it works when I use it somewhere else or if I create a local array and then pass that array as an argument.

void printA(){
    turnOFFAll(digitPins); //To reset display before displaying a letter
    digitalWrite(digitPins[1], HIGH); //Trying just one for now, gives error
};
Error:  invalid types 'uint8_t {aka unsigned char}[int]' for array subscript
    digitalWrite(digitPins[1], HIGH);

However, this works well. Even though Im doing the same thing except using the variable 'i' in place of the constant that I was using and setting the output to LOW rather than HIGH.

void turnOFFAll(byte digitPins[]){
    for(int i = 0; i <= 7; i++){
        digitalWrite(digitPins[i], LOW);
    }
}
Borisonekenobi
  • 469
  • 4
  • 15
Spenzr
  • 1
  • 1

0 Answers0