Ethernet SHIELD string

Hi good afternoon people, i made an AC dimmer control and works good but the question here is that i want to turn on individually one lamp by one, with this code when i turn on the first lamp its okay but when i turn on the second lamp the first turn on too and if i connect another lamp the three lamps turn on and off, so i want to know how can i do this individually? if someone can help me please :slight_smile: thank you.

//Programa para control de AC 120V/60HZ

#include <SPI.h>
#include <String.h>
#include <EthernetV2_0.h>
#include <LiquidCrystal.h>
#include <TimerOne.h>
#define W5200_CS  10
#define SDCARD_CS 4

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   // Escribimos la direccion MAC de el Ethernet Shield
byte ip[] = { 192, 168, 1, 2 };                       // Escribimos la IP dentro del rango de la red
EthernetServer server(80);                           // Iniciamos el puerto de servicio

volatile int i=0;                   // se declara una variable para utilizarla como contador
volatile boolean zero_cross=0;     // variable tipo boleana para almacenar el switch cuando hay un cruce a cero
int AC_pin = 3;                   // pin de salida para el Optotriac
int AC_pin2 = 7;
int pas = 8;                     //Pasos de 8 en 8
int dim = 128;
int dim3 = 256;
int freqStep = 75;
String readString = String(30);  // tamaño de string para buscar las direcciones establecidas(Ligarled,Desligarled)


void setup(){
  Serial.begin(9600);           // Inicia la comunicacion Serial
  pinMode(SDCARD_CS,OUTPUT);
  digitalWrite(SDCARD_CS,HIGH);
  
  pinMode (AC_pin,OUTPUT);
  pinMode (AC_pin2,OUTPUT);
  Ethernet.begin(mac, ip);      // Inicia la comunicacion etehernet
  server.begin();
  attachInterrupt(0, zero_cross_detect, RISING);    //  Añade una interrupcion en el pin2 para la deteccion por cero
  Timer1.initialize(freqStep);                      // Inicializamos la libreria timer one para la frecuencia que necesitamos
  Timer1.attachInterrupt(dim_check, freqStep);      // Usamos la libreria timerone para añadir una interrupcion
}                              

void zero_cross_detect() {    
  zero_cross = true;               // Ajustamos el valor booleano a verdadero para avisar que paso por cero 
  i=0;
  digitalWrite(AC_pin, LOW);
  digitalWrite(AC_pin2,LOW);
}  

void dim_check() {               // Encendemos el triac al tiempo apropiado                 
    if(i>=dim) {                     
      digitalWrite(AC_pin, HIGH);  // Encendemos la luz 
    }
    if(i>=dim3) {                     
      digitalWrite(AC_pin2, HIGH);  // Encendemos la luz 
    }
            i++;  // se incrementa el time step counter                     
    }                                

void loop(){
  
  EthernetClient client = server.available();  // Creamos la conexion a cliente

  if (client) {
    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();
       
        {
          readString += (c);          // almacena los caracteres o cadena de strings
        }
        
        if (c == '\n')        //el envio por http termina 

          {

            if(readString.indexOf("LAMPOFF")>=0)
         {
            dim=128;
          } 
 
 if(readString.indexOf("LAMPON")>=0)
          {
        dim=0;
    }
    if(readString.indexOf("LAMPON2")>=0)
          {
            dim3=129;
           }
            if(readString.indexOf("LAMPOFF2")>=0)
          {
            dim3=256;
           }
        client.println("HTTP/1.1 200 OK");
        client.println("Content-Type: text/html");
        client.println();
          
        readString="";

        client.stop();
        }
      }
    }
  }
  Serial.print("dim=");
  Serial.print(dim);
   Serial.print("    dim3=");
  Serial.print(dim3);
  Serial.print('\n');
  delay (100);

}

Think about it. "LAMPON2" and "LAMPOFF2" contain "LAMPON" and "LAMPOFF".

SurferTim:
Think about it. "LAMPON2" and "LAMPOFF2" contain "LAMPON" and "LAMPOFF".

Hey thank you i already change the strings so the code works great, thank you for your help.

Best Regards.