control relay by condition value from database mysql

i use arduino uno and ethernet shield

i want to control my relay by the value of database mysql but turning off or on is not work for relay

-if value is LOW will write HIGH to pin 1
-if value is HIGH will write LOW to pin 1

this is my code

#include <Ethernet.h>
#include <MySQL_Connection.h>
#include <Dns.h>
#include <MySQL_Cursor.h>

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

char hostname[] = ""; // change to your server's hostname/URL
char user[] = "
"; // MySQL user login username
char password[] = "****"; // MySQL user login password

// Sample query
char query[] = "SELECT * FROM pV6swOq6U6.static where user='trial' and pin='1'";

IPAddress server_ip;
EthernetClient client;
MySQL_Connection conn((Client *)&client);
DNSClient dns_client; // DNS instance
// Create an instance of the cursor passing in the connection
MySQL_Cursor cur = MySQL_Cursor(&conn);

void setup() {
Serial.begin(115200);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
while (!Serial); // wait for serial port to connect
Ethernet.begin(mac_addr);
// Begin DNS lookup
dns_client.begin(Ethernet.dnsServerIP());
dns_client.getHostByName(hostname, server_ip);
Serial.println(server_ip);
// End DNS lookup
Serial.println("Connecting...");
if (conn.connect(server_ip, 3306, user, password)) {
delay(1000);
}
else
Serial.println("Connection failed.");
}

void loop() {
// Initiate the query class instance
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
// Execute the query
cur_mem->execute(query);
// Fetch the columns and print them
column_names *cols = cur_mem->get_columns();
Serial.println();
// Read the rows and print them
row_values *row = NULL;
do {
row = cur_mem->get_next_row();
if (row != NULL) {
String pin_value_1=row->values[5];
Serial.println("\npin value = \n");
Serial.print(pin_value_1);
if(pin_value_1=="LOW")
{
digitalWrite(1, HIGH);
Serial.print("send high to pin 1");
}
else if(pin_value_1=="HIGH")
{
digitalWrite(1, LOW);
Serial.print("send low to pin 1");
}
}
}
while (row != NULL);
// Deleting the cursor also frees up memory used
delete cur_mem;
}

That program DOES work. It does exactly what you told it to do. That it doesn't do what you expect means that your expectations are wrong.

But, since you haven't told us what the program actually does, what the serial output shows, or how the relay is connected, you can't expect us to tell you why your expectations are wrong.

sorry for late response, but for this case has been solved of me :slight_smile:
btw thanks for your attention.