phase control using multiple SSR's

So I've read a lot of threads where the possibility of phase control is debated. The main issue seems to be the slowness of SSRs to trigger. The second problem is that a triac will have 230v on the variable resistor, which means it's impossible to use transistors. And a triac needs 10v to trigger anyway, which the arduino doesn't put out.

I think I have found a solution but need help coding it.

I am using a 8 SSR module, so 8 inputs. Across each pair is a resistor. The output of the first feeds the input of the second (link) and so on. Lets use 50k resistors. The end result is 9 possible outcomes.

  1. No relays activated. Sum the total of resistors (400k)
  2. Relay 1 activated. Sum the other 7 resistors (350k)
  3. Relay 1-2 activated. Sum the other 6 resistors (300k)
  4. Relay 1-3 activated. Sum the other 5 resistors (250k)
  5. Relay 1-4 activated. Sum the other 4 resistors (200k)
  6. Relay 1-5 activated. Sum the other 3 resistors (150k)
  7. Relay 1-6 activated. Sum the other 2 resistors (100k)
  8. Relay 1-7 activated. Sum the other 1 resistors (50k)
  9. Relay 1-8 activated. No resistors (0k)

This resistance is put across the triac. Thus giving 9 different output levels at 230v.

The controlling variable is current going to the battery. I want a min of 1A going to the battery. All excess solar capacity should be sent to the triac.for simplicity let's say the triac range is 1 to 9A.

Output pins (1,2,3,4,5,6,7,8)
So if A (battery current) > 2, increase triac (make next output pin in string go high)
if A < 2, decrease triac (make current highest pin in string go low)
default triac would be 400k ie no pins high

How to write this?

Phase control with an SSR is tied to whether said SSR is zero-crossing or random fire.
With "ZC", phase control is not possible.

Does this look OK?

void setup ()  {
j=0
float amps
string pin1="LOW" 
string pin2="LOW" 
string pin3="LOW" 
string pin4="LOW" 
string pin5="LOW" 
string pin6="LOW" 
string pin7="LOW" 
string pin8="LOW" 
} 

void loop ()  {

 if (j>=0 AND amps>2 AND j<7) { j=j+1 } 
else if (j>0 AND amps<2 )  { j=j-1 } 
 
if (j>0) { pin1=HIGH } else { pin1=LOW } 
if (j>1) { pin2=HIGH } else { pin2=LOW } 
if (j>2) { pin3=HIGH } else { pin3=LOW } 
if (j>3) { pin4=HIGH } else { pin4=LOW } 
if (j>4) { pin5=HIGH } else { pin5=LOW } 
if (j>5) { pin6=HIGH } else { pin6=LOW } 
if (j>6) { pin7=HIGH } else { pin7=LOW } 
if (j>7) { pin8=HIGH } else { pin8=LOW } 

for (wj=0; wj<=8; wj=wj+1); {
digitalwrite(wj, string(pin + j) 
} 
delay 1000
}/code]