First Project - Wilson DT4G cell repeater

So this is my first ever arduino project and I haven't coded anything in 15 or so years. It's pretty simple. I have a cell repeater. It has four 10K potentiometers on it that adjust the gain. Two of them need adjusting regularly. My plan is to use an arduino and digital potentiometers to adjust the gain automatically. Basically, when it's adjusted right the light turns green. You want the most gain possible so my plan is when the green light goes out, to have the pot adjust to max gain and then slowly back off until it goes green again.
I know I could write it so it would save the wiper value and adjust from where it was, but I'm not terribly concerned about losing signal for a minute while it "sweeps the dial" since I already lose signal longer than that from lack of adjustment. I may improve it in the future and try to fine tune it but first I'd like to just write some code and have it work and do something in the real world. That would be awesome.
So, I'm hoping someone might be able to look over my code and see if they see any big no-nos. It compiles and I think it will work, but as this is my first project I'm a bit cautious.

#include <SPI.h> //MOSI on 11; MISO on 12(not used); SCK on 13;


const int ssPin1 = 9; //CS pin for first digipot
const int ssPin2 = 10; //CS pin for second digipot
const int ledPin1 = 7; //LED 1 connected to pin 7
const int ledPin2 = 8; //LED 2 connected to pin 8
const int potPwr = 4; //POA from digipot connected to pin 4


void setup() {
 
  pinMode(ledPin1, INPUT);
  pinMode(ledPin2, INPUT);
  pinMode(ssPin1, OUTPUT);
  pinMode(ssPin2, OUTPUT);
  pinMode(potPwr, OUTPUT);
  SPI.begin();
  Serial.begin(9600); //for debugging if needed later
  digitalWrite(ssPin1, HIGH);
  digitalWrite(ssPin2, HIGH);
  delay(10);
  digitalWrite(potPwr, HIGH);
  delay(5);

}

void loop() {
  
  int ledState1 = digitalRead(ledPin1); //Check state of LED 1
  int ledState2 = digitalRead(ledPin2); //Check state of LED 2
  int wiperVal1 = 128; //Set wiper to full on ?INVERTED VALUES?
  int wiperVal2 = 128; //May have to switch to 0 and count up later? Need to test
  
  while (ledState1 != HIGH) //do this until LED 1 comes on
  {
    digitalWrite(ssPin1, LOW); //Set CS pin LOW for writing
    SPI.transfer(0); //Set write address
    SPI.transfer(wiperVal1); //Set wiper value to digipot
    digitalWrite(ssPin1, HIGH); //Set CS pin HIGH to end write
    delay(1500); //Wait 1.5 seconds for LED to change. May adjust later.
    wiperVal1--; //Increment WiperVal down; should get reset to 128 if led turns on.
    ledState1 = digitalRead(ledPin1); //Check if LED is on
  }
  
  while (ledState2 != HIGH) //do this until LED 2 comes on
  {
    digitalWrite(ssPin2, LOW); //Set CS pin LOW for writing
    SPI.transfer(0); //Set write address
    SPI.transfer(wiperVal2); //Set wipervalue to digipot
    digitalWrite(ssPin2, HIGH); //Set CS ping HIGH to end write
    delay(1500); //Wait for LED to change
    wiperVal2--; //Increment WiperVal down; should get reset to 128 if led turns on.
    ledState2 = digitalRead(ledPin2); //Check if LED is on
  }

    //If both LEDs are on it should be doing nothing at all
}

So I've already made some edits to the code. I realized that there have been times when I have lowered the setting on the pot and gotten all the way to the bottom without the light ever turning green. So I added an if loop inside each while loop that will see if the digipot is set to 0 and if so change it to 128 to cycle through again. I also added some more comments.

#include <SPI.h> //MOSI on 11; MISO on 12(not used); SCK on 13;

const int ssPin1 = 9; //CS pin for first MCP4131
const int ssPin2 = 10; //CS pin for second MCP4131
const int ledPin1 = 7; //LED 1 connected to pin 7
const int ledPin2 = 8; //LED 2 connected to pin 8
const int potPwr = 4; //POA from both MCP4131 connected to pin 4

void setup() {
 
  pinMode(ledPin1, INPUT);
  pinMode(ledPin2, INPUT);
  pinMode(ssPin1, OUTPUT);
  pinMode(ssPin2, OUTPUT);
  pinMode(potPwr, OUTPUT);
  SPI.begin();
  Serial.begin(9600); //for debugging if needed later
  digitalWrite(ssPin1, HIGH); //MCP4131 CS pin set HIGH to deactivate write
  digitalWrite(ssPin2, HIGH); //MCP4131 CS pin set HIGH to deactivate write
  delay(10);
  digitalWrite(potPwr, HIGH); //turn on both MCP4131
  delay(5);

}

void loop() {
  
  int waitTime = 1000;
  int ledState1 = digitalRead(ledPin1); //Check state of LED 1
  int ledState2 = digitalRead(ledPin2); //Check state of LED 2
  int wiperVal1 = 128; //Set wiper to full on ?INVERTED VALUES?
  int wiperVal2 = 128; //May have to switch to 0 and count up later? Need to test
  
  while (ledState1 != HIGH) //do this until LED 1 comes on
  {
    digitalWrite(ssPin1, LOW); //Set CS pin LOW for writing
    SPI.transfer(0); //Set write address
    SPI.transfer(wiperVal1); //Set wiper value to digipot
    digitalWrite(ssPin1, HIGH); //Set CS pin HIGH to end write
    delay(waitTime); //Wait 1.5 seconds for LED to change. May adjust later.
    if (wiperVal1 == 0) //Check if WiperVal made it to 0 without turning LED on.
    {
      wiperVal1 = 128; //If yes, set wiper back to 128 and try again
    }
    else //if it's not 0 then decrement by 1
    {
      wiperVal1--; //Increment WiperVal down; should get reset to 128 if led turns on.
    }
    
    ledState1 = digitalRead(ledPin1); //Check if LED is on
  }
  
  while (ledState2 != HIGH) //do this until LED 2 comes on
  {
    digitalWrite(ssPin2, LOW); //Set CS pin LOW for writing
    SPI.transfer(0); //Set write address
    SPI.transfer(wiperVal2); //Set wipervalue to digipot
    digitalWrite(ssPin2, HIGH); //Set CS ping HIGH to end write
    delay(waitTime); //Wait for LED to change
    if (wiperVal2 == 0) //Check if WiperVal made it to 0 without turning LED on.
    {
      wiperVal2 = 128; //If yes, set wiper back to 128 and try again
    }
    else //if it's not 0 then decrement by 1
    {
      wiperVal2--; //Increment WiperVal down; should get reset to 128 if led turns on.
    }
    ledState2 = digitalRead(ledPin2); //Check if LED is on
  }

    //If both LEDs are on it should be doing nothing at all
}

It works. At least it functions as I thought it would outside of the DT4G.

I'm thinking I'll need some pull down resistors on pins 7 and 8. I get some HIGHS on those pins when they shouldn't be going HIGH. Maybe that won't be a problem when it's wired into the DT4G LEDs. I don't know... I'm pretty green in both hardware and software.

I've connected the arduino and digital potentiometer to the DT4G on the first LED and pot. It's also running off the DT4G's 5v input. So far so good. It is adjusting the potentiometer until the LED turns green (red, orange, and off are also options). I would have tested the second LED and pot as well but they are harder to get to so I didn't want to go to the trouble until I had verified that my plan would actually work. I have made a few more changes to the code but I will hold off until I'm finished to update that. One thing I didn't expect. The maximum voltage the trim pots are putting out now is about 2.5v. So the 5v from the digital pots would have been too much.