need to pass "chanel #" to commonly called function,

so i have a system with 4 PWM outputs, and i would like to have 1 common function to make the adjustments, by passing it the channel # i want adjusted.

void decreasepwm1()
{
  if (pwm1 > pwmstep2x)
  {
    pwm1 = pwm1-pwmstep2x;

    u8x8.setCursor(14,4);
    u8x8.print(" ");
    if (pwm1 >= 0)
    {
      updatepwm1();
    }
    else
    {
      pwm1 = 0;
      updatepwm1();
    }
  }
  else
  {
    pwm1 = 0;
    updatepwm1();
  }

}

as it is now i have 4 of these, where each of the "1"'s is a 2 or 3 or 4, lotsa long code

So i thought maybe i could do this:

void decreasepwmnum(char pwmnum, char updatepwmnum)
{
  if (pwmnum > pwmstep2x)
  {
    pwmnum = pwmnum-pwmstep2x;

    u8x8.setCursor(14,4);
    u8x8.print(" ");
    if (pwmnum >= 0)
    {
      updatepwmnum();
    }
    else
    {
      pwmnum = 0;
      updatepwmnum();
    }
  }
  else
  {
    pwmnum = 0;
    updatepwmnum();
  }

}

if i call it like this:

void loop()
{
decreasepwmnum(char pwm1,char updatepwm1);
decreasepwmnum(pwm2, updatepwm2);
// 3 and 4 to follow
}

but i got this error:
'updatepwmnum' cannot be used as a function

I even thought about this:

void decreasepwmnum(int chan);
{
  if (pwm(chan) > pwmstep2x)
  {
    pwm(chan) = pwmnum-pwmstep2x;

    u8x8.setCursor(14,4);
    u8x8.print(" ");
    if (pwm(chan) >= 0)
    {
      updatepwm(chan)();
    }
    else
    {
      pwmnum = 0;
      updatepwm(chan)();
    }
  }
  else
  {
    pwmnum = 0;
    updatepwm(chan)();
  }

}

but i get a
'pwm' was not declared in this scope error

ive been through lots and lots of youtube vids, and tutorials, and I'm just not wrapping my head around how to pass in the chan #'s

void loop()
{
decreasepwmnum(char pwm1,char updatepwm1);
decreasepwmnum(pwm2, updatepwm2);
// 3 and 4 to follow
}

You're close, but a function call doesn't have the type names in it. It wouldn't have the char. And you'd have to have char variables already created (with whatever names you want) that hold the data you want to pass in already and you put those variables into the call.

Post your whole code and maybe we can help you sort out what you need to be doing here.

this is definately a work in progress,

i have to break this into multiple posts cause of the char limit…

so, here is part 1

current version of 4 chan attempt:

/*
   Solar powered dehumidifyer
   This code and unit use the "waste" from my PWM solar charge controller
   Written by Joe Peppers, 8/25/2019

*/
//  UNO BOARD

// universal settings
float onvoltage = 16.0;
float offvoltage = 14.5;
float outtankdelta = 2;
int delaytime = 2000; //miliseconds so 1000=1 second
float voltcorrect = .02441406;
int readsensorloopcount = 1;
float dewptoffset = 2;  // this sets how much cooler the plate needs to be than the dewpoint
int pwmstepsize = 25;  // defines how bigga adjustment each step is
int dhttempFcorrection = 2; // I've found that the DHT reads just a tad high, this fixes it



#include <U8x8lib.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <FastIO.h>
#include <I2CIO.h>

#include <OneWire.h>
#include <DallasTemperature.h>


//assign names for output pins
int outloop = 5;
int inloop = 6;
int cooler1 = 9;
int cooler2 = 10;
int cooler3 = 3;
int cooler4 = 11;
int cooler1DPreached = 2;
int cooler2DPreached = 4;
int cooler3DPreached = 12;
int cooler4DPreached = 13;
//ANALOG INPUTS
float voltin = A0;


//THESE SET THE BUS SPEED FOR THE I2C
//u8g2.setBusClock(200000);
//u8g2.setBusClock(400000);

// constructor for oled display

U8X8_SSD1327_EA_W128128_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);



#define ONE_WIRE_BUS 7

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
DeviceAddress outtemp = { 0x28, 0xAA, 0x62, 0xCB, 0x53, 0x14, 0x01, 0xA4 }; // sensor 8
DeviceAddress platetemp1 = { 0x28, 0xAA, 0x93, 0xE4, 0x53, 0x14, 0x01, 0x25 };  // sensor 9
DeviceAddress platetemp2 = { 0x28, 0xAA, 0x5D, 0xE7, 0x53, 0x14, 0x01, 0x2D }; // sensor 7
DeviceAddress platetemp3 = { 0x28, 0xAA, 0xBA, 0xE6, 0x53, 0x14, 0x01, 0x29 }; //sensor 5
DeviceAddress platetemp4 = { 0x28, 0xAA, 0x65, 0xE4, 0x53, 0x14, 0x01, 0x1F }; //sensor 6
DeviceAddress tanktemp = { 0x28, 0xAA, 0x94, 0xE2, 0x53, 0x14, 0x01, 0x7D }; // sensor 10



// for the DHT11 temp and humidity sensor
#define DHTPIN 8
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);

//variables
float outtempC = 0;
float outtempF = 0;
float tanktempC = 0;
float tanktempF = 0;
float platetempC1 = 0;
float platetempF1 = 0;
float platetempC2 = 0;
float platetempF2 = 0;
float platetempC3 = 0;
float platetempF3 = 0;
float platetempC4 = 0;
float platetempF4 = 0;
float voltage = 0;
float dhthum = 0;
float dhttempF = 0;
float dewpt = 0;
int pwm1 = 0;
int pwm2 = 0;
int pwm3 = 0;
int pwm4 = 0;
int pwmstep2x = 2 * pwmstepsize;
int pwm1p = 0;
int pwm2p = 0;
int pwm3p = 0;
int pwm4p = 0;
int voltgood = 0;




void setup() {
  // put your setup code here, to run once:


  pinMode(outloop, OUTPUT); // outside loop pin 5
  pinMode(inloop, OUTPUT); // inside loop pin 6
  pinMode(cooler1, OUTPUT); //
  pinMode(cooler2, OUTPUT); //
  pinMode(cooler3, OUTPUT); //
  pinMode(cooler4, OUTPUT); //
  pinMode(cooler1DPreached, OUTPUT);
  pinMode(cooler2DPreached, OUTPUT);
  pinMode(cooler3DPreached, OUTPUT);
  pinMode(cooler4DPreached, OUTPUT);
  digitalWrite(outloop, HIGH); //LOW=ON ---RELAY
  digitalWrite(inloop, HIGH); //LOW=ON ---RELAY
  digitalWrite(cooler1DPreached, HIGH); //LOW=ON ----LED WIRED TO + AND PIN----
  digitalWrite(cooler2DPreached, HIGH); //LOW=ON ----LED WIRED TO + AND PIN----
  digitalWrite(cooler3DPreached, HIGH); //LOW=ON ----LED WIRED TO + AND PIN----
  digitalWrite(cooler4DPreached, HIGH); //LOW=ON ----LED WIRED TO + AND PIN----


  u8x8.begin();// oled display starter

  u8x8.setFont(u8x8_font_chroma48medium8_r);//sets font of OLED
  u8x8.setCursor(0, 0);
  u8x8.print("IN");
  u8x8.setCursor(0, 1);
  u8x8.print("HUM");
  u8x8.setCursor(0, 2);
  u8x8.print("DPT");
  u8x8.setCursor(0, 3);
  u8x8.print("OUT");
  u8x8.setCursor(0, 4);
  u8x8.print("TNK");
  u8x8.setCursor(0, 5);
  u8x8.print("PL1");
  u8x8.setCursor(0, 6);
  u8x8.print("PL2");
  u8x8.setCursor(0, 7);
  u8x8.print("PL3");
  u8x8.setCursor(0, 8);
  u8x8.print("PL4");
  u8x8.setCursor(0, 9);
  u8x8.print("VLT");
  u8x8.setCursor(9, 0);
  u8x8.print("Tpmp");
  u8x8.setCursor(9, 1);
  u8x8.print("Opmp");
  u8x8.setCursor(11, 4);
  u8x8.print("PWM1");
  u8x8.setCursor(11, 6);
  u8x8.print("PWM2");
  u8x8.setCursor(11, 8);
  u8x8.print("PWM3");
  u8x8.setCursor(11, 10);
  u8x8.print("PWM4");


/// continue to second post





}

to be continued due to char lim

i have the working 2 chan version i’m trying to expand to 4 chan and need to clean this mess up: but i’ll have to post that in a sep post due to post char length restrictions

part 2

  TCCR0B = TCCR0B & B11111000 | B00000011;    // set timer 0 divisor to    64 for PWM frequency of   976.56 Hz (The DEFAULT)
  TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to     1 for PWM frequency of 31372.55 Hz

  TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to     1 for PWM frequency of 31372.55 Hz

  dht.begin();

  sensors.begin();
  // resolution 9=.5C@93.75ms  10=.25C@187.5ms 11=.125C@375ms 12=.0625C@ 750ms
  sensors.setResolution(outtemp, 10);
  sensors.setResolution(platetemp1, 10);
  sensors.setResolution(platetemp2, 10);
  sensors.setResolution(platetemp3, 10);
  sensors.setResolution(platetemp4, 10);
  sensors.setResolution(tanktemp, 10);
}


void readsensors() {
  // reading the DS18b20's
  sensors.requestTemperaturesByAddress(outtemp);
  sensors.requestTemperaturesByAddress(platetemp1);
  sensors.requestTemperaturesByAddress(platetemp2);
  sensors.requestTemperaturesByAddress(platetemp3);
  sensors.requestTemperaturesByAddress(platetemp4);
  sensors.requestTemperaturesByAddress(tanktemp);
  outtempC = sensors.getTempC(outtemp);
  outtempF = DallasTemperature::toFahrenheit(outtempC);
  platetempC1 = sensors.getTempC(platetemp1);
  platetempF1 = DallasTemperature::toFahrenheit(platetempC1);
  platetempC2 = sensors.getTempC(platetemp2);
  platetempF2 = DallasTemperature::toFahrenheit(platetempC2);
  platetempC3 = sensors.getTempC(platetemp3);
  platetempF3 = DallasTemperature::toFahrenheit(platetempC3);
  platetempC4 = sensors.getTempC(platetemp4);
  platetempF4 = DallasTemperature::toFahrenheit(platetempC4);
  tanktempC = sensors.getTempC(tanktemp);
  tanktempF = DallasTemperature::toFahrenheit(tanktempC);
  voltage = (analogRead(voltin) * voltcorrect);

 
  dhthum = dht.readHumidity();

  dhttempF = dht.readTemperature(true) - dhttempFcorrection;

  float k;
  k = log(dhthum / 100) + (17.62 * dhttempF) / (243.12 + dhttempF);
  dewpt = 243.12 * k / (17.62 - k);
}


void updateOLED()
{

  u8x8.setCursor(4, 0);
  u8x8.print(dhttempF, 1);
  u8x8.setCursor(4, 1);
  u8x8.print(dhthum, 1);
  u8x8.setCursor(4, 2);
  u8x8.print(dewpt, 1);
  u8x8.setCursor(4, 3);
  u8x8.print(outtempF, 1);
  u8x8.setCursor(4, 4);
  u8x8.print(tanktempF, 1);
  u8x8.setCursor(4, 5);
  u8x8.print(platetempF1, 1);
  u8x8.setCursor(4, 6);
  u8x8.print(platetempF2, 1);
  u8x8.setCursor(4, 7);
  u8x8.print(platetempF3, 1);
  u8x8.setCursor(4, 8);
  u8x8.print(platetempF4, 1);
  u8x8.setCursor(4, 9);
  u8x8.print(voltage, 1);

  pwm1p = pwm1 / 25;
  pwm2p = pwm2 / 25;
  pwm3p = pwm3 / 25;
  pwm4p = pwm4 / 25;

  u8x8.setCursor(12, 4);
  u8x8.print(pwm1p);
  u8x8.setCursor(12, 7);
  u8x8.print(pwm2p);
  u8x8.setCursor(0, 8);
  u8x8.setCursor(12, 9);
  u8x8.print(pwm3p);
  u8x8.setCursor(12, 11);
  u8x8.print(pwm4p);
  u8x8.setCursor(0, 10);
  u8x8.print("extra");
  u8x8.setCursor(0, 11);
  u8x8.print("extra");

}


void updatepwm1()
{
  analogWrite(cooler1, pwm1);
  insidepump();
  pwm1p = pwm1 / 25;
  u8x8.setCursor(12, 4);
  u8x8.print(pwm1p);

}


void updatepwm2()
{
  analogWrite(cooler2, pwm2);
  insidepump();
  pwm2p = pwm2 / 25;
  u8x8.setCursor(12, 7);
  u8x8.print(pwm2p);

}


void updatepwm3()
{
  analogWrite(cooler3, pwm3);
  insidepump();
  pwm3p = pwm3 / 25;
  u8x8.setCursor(12, 9);
  u8x8.print(pwm3p);

}


void updatepwm4()
{
  analogWrite(cooler4, pwm4);
  insidepump();
  pwm4p = pwm4 / 25;
  u8x8.setCursor(12, 11);
  u8x8.print(pwm4p);

}


void adjustpwm1()
{
  if (platetempF1 >= 35)
  {
    if (platetempF1 >= dewpt - dewptoffset)
    {
      digitalWrite(cooler1DPreached, HIGH);
      if (pwm1 <= 240)
      {
        if (voltageevaluator)
        {
          u8x8.setCursor(14, 4);
          u8x8.print(" ");
          pwm1 = pwm1 + pwmstepsize;
          updatepwm1();
        }
      }
      else
      {
        u8x8.setCursor(14, 4);
        u8x8.print("0");
        adjustpwm2();

      }
    }
    else
    {
      digitalWrite(cooler1DPreached, LOW);
      if (pwm1 >= pwmstepsize + 1)
      {
        pwm1 = pwm1 - pwmstepsize;
      }
      else
      {
        pwm1 = 0;
      }
      u8x8.setCursor(14, 4);
      u8x8.print(" ");
      updatepwm1();
    }
  }
  else
  {
    decreasepwm1();
  }
}


void adjustpwm2()
{
  if (platetempF2 >= 35)
  {
    if (platetempF2 >= dewpt - dewptoffset)
    {
      if (pwm2 <= 240)
      {

        u8x8.setCursor(14, 7);
        u8x8.print(" ");
        pwm2 = pwm2 + pwmstepsize;
        updatepwm2();
      }
      else
      {

        u8x8.setCursor(14, 7);
        u8x8.print("0");
      }
    }
    else
    {
      if (pwm2 >= pwmstepsize + 1)
      {
        pwm2 = pwm2 - pwmstepsize;
      }
      else
      {
        pwm2 = 0;
      }

      u8x8.setCursor(14, 7);
      u8x8.print(" ");
      updatepwm2();
    }
  }
  else
  {
    decreasepwm2();
  }
}


void decreasepwm1()
{
  if (pwm1 > pwmstep2x)
  {
    pwm1 = pwm1 - pwmstep2x;
    //  digitalWrite(cooler1maxled, HIGH);
    u8x8.setCursor(14, 4);
    u8x8.print(" ");
    if (pwm1 >= 0)
    {
      updatepwm1();
    }
    else
    {
      pwm1 = 0;
      updatepwm1();
    }
  }
  else
  {
    pwm1 = 0;
    updatepwm1();
  }

}


void decreasepwm2()
{
  if (pwm2 > pwmstep2x)
  {
    pwm2 = pwm2 - pwmstep2x;
    //  digitalWrite(cooler2DPreached, HIGH);
    u8x8.setCursor(14, 7);
    u8x8.print(" ");
    if (pwm2 >= 0)
    {
      updatepwm2();
    }
    else
    {
      pwm2 = 0;
      updatepwm2();
      //      decreasepwm1();
    }
  }
  else
  {
    pwm1 = 0;
    updatepwm1();
  }
}

int voltageevaluator()
{
  if (voltage >= onvoltage)
  {
    //      adjustpwm1();
    return 1;
  }
  else if (voltage <= offvoltage)
  {
    //      decreasepwm2();
    return 0;
  }
}

void insidepump()
{
  if (pwm1 > 0 || pwm2 > 0)
  {
    digitalWrite(inloop, LOW);
    u8x8.setCursor(14, 0);
    u8x8.print("ON");
  }
  else
  {
    digitalWrite(inloop, HIGH);
    u8x8.setCursor(14, 0);
    u8x8.print("  ");
  }
}

void outlooppump()
{

  if (outtempF <= tanktempF - outtankdelta)
  {
    digitalWrite(outloop, LOW); //LOW is on
    u8x8.setCursor(14, 1);
    u8x8.print("ON");

  }
  else if (outtempF >= tanktempF)
  {
    digitalWrite(outloop, HIGH); // high is off
    u8x8.setCursor(14, 1);
    u8x8.print("  ");

  }
}

void loop()
{
  // put your main code here, to run repeatedly:

  readsensors();
  outlooppump();
  updateOLED();

here is the actual working on the UNO 2 chan version… I’m particularly happy with the throttle up and down, and prioritization of 1 then 2…

//  UNO BOARD

// universal settings
float onvoltage = 16.0;
float offvoltage = 14.5;
float outtankdelta = 2;
int delaytime = 2000; //
float voltcorrect = .02441406;
int readsensorloopcount = 1;
float dewptoffset = 2;  // t
int pwmstepsize = 25;  // 
int dhttempFcorrection = 2; // 


#include <U8x8lib.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <FastIO.h>
#include <I2CIO.h>

#include <OneWire.h> 
#include <DallasTemperature.h>



int outloop = 5;
int inloop = 6;
int cooler1 = 9;
int cooler2 = 10;
int cooler1maxled = 2;
int cooler2maxled = 4;

float voltin = A0;


U8X8_SSD1327_EA_W128128_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);  



#define ONE_WIRE_BUS 7

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
DeviceAddress outtemp = { 0x28, 0xAA, 0x62, 0xCB, 0x53, 0x14, 0x01, 0xA4 }; // sensor 8
DeviceAddress platetemp1 = { 0x28, 0xAA, 0x93, 0xE4, 0x53, 0x14, 0x01, 0x25 };  // sensor 9
DeviceAddress platetemp2 = { 0x28, 0xAA, 0x5D, 0xE7, 0x53, 0x14, 0x01, 0x2D }; // sensor 7
DeviceAddress tanktemp = { 0x28, 0xAA, 0x94, 0xE2, 0x53, 0x14, 0x01, 0x7D }; // sensor 10




#define DHTPIN 8
#define DHTTYPE DHT11   // DHT 11
DHT dht(DHTPIN, DHTTYPE);



float outtempC = 0;
float outtempF = 0;
float tanktempC = 0;
float tanktempF = 0;
float platetempC1 = 0;
float platetempF1 = 0;
float platetempC2 = 0;
float platetempF2 = 0;
float voltage = 0;
float dhthum = 0;
float dhttempF = 0;
float dewpt = 0;
int pwm1 = 0;
int pwm2 = 0;
int pwmstep2x = 2*pwmstepsize;
int pwm1p = 0;
int pwm2p = 0;





void setup() {



  pinMode(outloop, OUTPUT); // outside loop pin 5
  pinMode(inloop, OUTPUT); // inside loop pin 6
  pinMode(cooler1, OUTPUT); // 
  pinMode(cooler2, OUTPUT); // 
  pinMode(cooler1maxled, OUTPUT);
  pinMode(cooler2maxled, OUTPUT);
  digitalWrite(outloop,HIGH);//LOW=ON ---RELAY
  digitalWrite(inloop,HIGH);//LOW=ON ---RELAY
  digitalWrite(cooler1maxled,HIGH);//LOW=ON ----LED WIRED TO + AND PIN----
  digitalWrite(cooler2maxled,HIGH);//LOW=ON ----LED WIRED TO + AND PIN----


  u8x8.begin();// oled display starter

  u8x8.setFont(u8x8_font_chroma48medium8_r);//sets font of OLED
  u8x8.setCursor(0, 0);
  u8x8.print("IN");
  u8x8.setCursor(0, 1);
  u8x8.print("HUM");
  u8x8.setCursor(0, 2);
  u8x8.print("DPT");
  u8x8.setCursor(0, 3);
  u8x8.print("OUT");
  u8x8.setCursor(0, 4);
  u8x8.print("TNK");
  u8x8.setCursor(0, 5);
  u8x8.print("PL1");
  u8x8.setCursor(0, 6);
  u8x8.print("PL2");
  u8x8.setCursor(0, 7);
  u8x8.print("VLT");
  u8x8.setCursor(9,0);
  u8x8.print("Tpmp");
  u8x8.setCursor(9,1);
  u8x8.print("Opmp");
  u8x8.setCursor(11,3);
  u8x8.print("PWM1");
  u8x8.setCursor(11,6);
  u8x8.print("PWM2");
  TCCR0B = TCCR0B & B11111000 | B00000011;    // set timer 0 divisor to    64 for PWM frequency of   976.56 Hz (The DEFAULT)
------------------------------

TCCR1B = TCCR1B & B11111000 | B00000001;    // set timer 1 divisor to     1 for PWM frequency of 31372.55 Hz


TCCR2B = TCCR2B & B11111000 | B00000001;    // set timer 2 divisor to     1 for PWM frequency of 31372.55 Hz


dht.begin();

sensors.begin();

sensors.setResolution(outtemp, 10); 
sensors.setResolution(platetemp1, 10);
sensors.setResolution(platetemp2, 10);
sensors.setResolution(tanktemp, 10);
}


void readsensors(){

sensors.requestTemperaturesByAddress(outtemp);
sensors.requestTemperaturesByAddress(platetemp1);
sensors.requestTemperaturesByAddress(platetemp2);
sensors.requestTemperaturesByAddress(tanktemp);
outtempC = sensors.getTempC(outtemp);
outtempF = DallasTemperature::toFahrenheit(outtempC);
platetempC1 = sensors.getTempC(platetemp1);
platetempF1 = DallasTemperature::toFahrenheit(platetempC1);
platetempC2 = sensors.getTempC(platetemp2);
platetempF2 = DallasTemperature::toFahrenheit(platetempC2);
tanktempC = sensors.getTempC(tanktemp);
tanktempF = DallasTemperature::toFahrenheit(tanktempC);
voltage = (analogRead(voltin)*voltcorrect);


dhthum = dht.readHumidity();

dhttempF = dht.readTemperature(true)-dhttempFcorrection;


float k;
k = log(dhthum/100) + (17.62 * dhttempF) / (243.12 + dhttempF);
dewpt = 243.12 * k / (17.62 - k);
}


void updateOLED()
{

u8x8.setCursor(4,0);
u8x8.print(dhttempF,1);
u8x8.setCursor(4,1);
u8x8.print(dhthum,1);
u8x8.setCursor(4,2);
u8x8.print(dewpt,1);
u8x8.setCursor(4,3);
u8x8.print(outtempF,1);
u8x8.setCursor(4,4);
u8x8.print(tanktempF,1);
u8x8.setCursor(4,5);
u8x8.print(platetempF1,1);
u8x8.setCursor(4,6);
u8x8.print(platetempF2,1);
u8x8.setCursor(4,7);
u8x8.print(voltage,1);

pwm1p = pwm1/25;
pwm2p = pwm2/25;

u8x8.setCursor(12,4);
u8x8.print(pwm1p);
u8x8.setCursor(12,7);
u8x8.print(pwm2p);
u8x8.setCursor(0,8);
u8x8.print("extra");
u8x8.setCursor(0,9);
u8x8.print("extra");
u8x8.setCursor(0,10);
u8x8.print("extra");
u8x8.setCursor(0,11);
u8x8.print("extra");

  
}


void updatepwm1()
{
  analogWrite(cooler1, pwm1);
  insidepump();
  pwm1p = pwm1/25;
  u8x8.setCursor(12,4);
  u8x8.print(pwm1p);

}


void updatepwm2()
{
  analogWrite(cooler2, pwm2);
  insidepump();
pwm2p = pwm2/25;
  u8x8.setCursor(12,7);
  u8x8.print(pwm2p);

}


void adjustpwm1()
{
  if (platetempF1 >= 35)
    {
      if (platetempF1 >= dewpt-dewptoffset)
      {
        if(pwm1 <= 240)
        {
          digitalWrite(cooler1maxled, HIGH);
          u8x8.setCursor(14,4);
          u8x8.print(" ");
          pwm1 = pwm1+pwmstepsize;
          updatepwm1();
        }
        else
        {
          digitalWrite(cooler1maxled, LOW);
          u8x8.setCursor(14,4);
          u8x8.print("0");
          adjustpwm2();
        }     
      }
      else
      {
        
        if(pwm1 >= pwmstepsize+1)
        {
        pwm1 = pwm1-pwmstepsize;
        }
        else
        {
          pwm1 = 0;
        }
        digitalWrite(cooler1maxled, HIGH);
        u8x8.setCursor(14,4);
        u8x8.print(" ");
        updatepwm1();
        
      }
    }
  else 
    {
      decreasepwm1();
    }
}

void adjustpwm2()
{
  if (platetempF2 >= 35)
    {
      if (platetempF2 >= dewpt-dewptoffset)
      {
        if (pwm2 <= 240)
        {
          digitalWrite(cooler2maxled, HIGH);
          u8x8.setCursor(14,7);
          u8x8.print(" ");
          pwm2 = pwm2+pwmstepsize;
          updatepwm2();
        }
        else
        {
          digitalWrite(cooler2maxled, LOW);
          u8x8.setCursor(14,7);
          u8x8.print("0");
        }
       
      }
      else
      {
        if(pwm2 >= pwmstepsize+1)
        {
        pwm2 = pwm2-pwmstepsize;
        }
        else
        {
          pwm2 = 0;
        }
        digitalWrite(cooler2maxled, HIGH);
        u8x8.setCursor(14,7);
        u8x8.print(" ");
        updatepwm2();
      }
    }
  else 
    {
      decreasepwm2();
    }
}

void decreasepwm1()
{
  pwm1 = pwm1-pwmstep2x;
  digitalWrite(cooler1maxled, HIGH);
  u8x8.setCursor(14,4);
  u8x8.print(" ");
  if (pwm1 >= 0)
  {
    updatepwm1();
  }
  else
  {
    pwm1 = 0;
    updatepwm1();
  }
}


void decreasepwm2()
{
  pwm2 = pwm2-pwmstep2x;
  digitalWrite(cooler2maxled, HIGH);
  u8x8.setCursor(14,7);
  u8x8.print(" ");
  if (pwm2 >= 0)
    {
      updatepwm2();
    }
    else
    {
      pwm2 = 0;
      updatepwm2();
      decreasepwm1();
    }
}


void voltageevaluator()
{
  if (voltage >= onvoltage)
    {
      adjustpwm1();
     
    }
  else if (voltage <= offvoltage)
    {
      decreasepwm2();
    }
}


void insidepump()
{
  if (pwm1 > 0 || pwm2 > 0)
    {
      digitalWrite(inloop,LOW);
      u8x8.setCursor(14,0);
      u8x8.print("ON");
    }
  else
    {
      digitalWrite(inloop,HIGH);
      u8x8.setCursor(14,0);
      u8x8.print("  ");
    }
}

void outlooppump()
{
  
  if (outtempF <= tanktempF-outtankdelta)
    {
      digitalWrite(outloop,LOW); //LOW is on
      u8x8.setCursor(14,1);
      u8x8.print("ON");
      
    }
  else if (outtempF >= tanktempF)
      {
      digitalWrite(outloop,HIGH); // high is off
      u8x8.setCursor(14,1);
      u8x8.print("  ");
      
    }
}

void loop() 
{


      readsensors();
      outlooppump();
      updateOLED();
      voltageevaluator();
 
}

Since you have a number of identical devices, an array will make it a lot easier and shorter to implement & debug your code.

An array of structs{} may we’ll be on the horizon - to become even more efficient, with easier to read code.

lastchancename:
Since you have a number of identical devices, an array will make it a lot easier and shorter to implement & debug your code.

An array of structs{} may we’ll be on the horizon - to become even more efficient, with easier to read code.

ok, so build an array, 1 for each chan
each array will hold the pwm1 and updatepwm1 (or 2 or 3 or 4)
then call to the appropriate array in the function?

so i tried this… nope…

String channel1[2]={"pwm1","updatepwm1"};
String channel2[2]={"pwm2","updatepwm2"};
String channel3[2]={"pwm3","updatepwm3"};
String channel4[2]={"pwm4","updatepwm4"};



void adjustpwm(String chnl[2])
{
    if (chnl[1] > pwmstep2x)
  {
    chnl[1] = chnl[1] - pwmstep2x;

    u8x8.setCursor(14, 4);
    u8x8.print(" ");
    if (chnl[1] >= 0)
    {
      chnl[2]();
    }
    else
    {
      chnl[1] = 0;
      chnl[2]();
    }
  }
  else
  {
    chnl[1] = 0;
    chnl[2]();
  }
}

and got this:
no match for ‘operator-’ (operand types are ‘String’ and ‘int’)

more googeling has me reading about “boost functions”
https://www.boost.org/doc/libs/1_36_0/doc/html/function.html
but i’m not sure that’ll do it

An array of struct, not of String.

It’s my bedtime, but learn about structure first so you have a place to keep your values

//Pseudo code—-
struct channel {
char valueA[10]
char valueB[10]
int number;
}
//create an array of four ‘channels
Channel myChannel[4];
:;:
//Assign and operate on values from the structures.
myChannel[0].valueA...;
myChannel[2].number = 456;

so its gonna look like this?

struct channel{
  char pwmnum[4]
  char pwmupdatenum[10]
}

struct channel chnl[4];
chnl1[0].pwmnum = "pwm1";
chnl1[0].pwmupdatenum = "updatepwm1";
chnl2[1].pwmnum = "pwm2";
chnl2[1].pwmupdatenum = "updatepwm2";
chnl3[2].pwmnum = "pwm3";
chnl3[2].pwmupdatenum = "updatepwm3";
chnl4[3].pwmnum = "pwm4";
chnl4[3].pwmupdatenum = "updatepwm4";

Yep, you’re heading in the right direction.
After looking at those names - if they’re really the values you’re going to use, you could simply generate them programmatically on the fly.

e.g.
word = “pwmnum”
chan = 2;

Use the appropriate method in each situation to generate the ‘string’ as you need it.

e.g.

sprintf (msgBuf, “%s%d”, word, chan);

msgBuf will contain “pwmnum2”

This isn’t always the best approach, but within your code, you need to understand what is needed, and the best way to get that value, while using the least memory and optimised code.

One of my favourite sayings...

There are at least three correct ways to code anything - but an infinite number of ways to get it wrong!

"programatically" sounds like a really good option, i'll have to think on that one....

if i continue with the AoS, how do i pass to the function with the chnl# i want it to operate on?

void decreasepwm(SEND IN CHANNEL #)
{
THEN HAVE ALL THE pwmnum AND updatepwmnum  UPDATE FROM THE ARRAY???
  if (pwmnum > pwmstep2x)  AND I WANT IT TO USE THE VALUE OF THE VARIABLE NAMED IN THE STRUCT

  {
    pwmnum = pwmnum - pwmstep2x;

    u8x8.setCursor(14, 4);
    u8x8.print(" ");
    if (pwmnum >= 0)
    {
      updatepwmnum();
    }
    else
    {
      pwmnum = 0;
      updatepwmnum();
    }
  }
  else
  {
    pwmnum = 0;
    updatepwmnum();
  }

}

It’s 5:25 am, so I’m going to crash for a while.
The other guys may point you in the right direction before I come back on...

(A ‘right’ direction!)