Ethernet - No pin activity...

I made a simple few lines of code which retrieve the Temperature readings from my MAX6675 module. But I also want it to control a relay which controls a light in response to the temperature. Unfortunately, even though it says it’s high, I’ve tested it with multiple LEDs, PNP Transistors, and even a multimeter - no output!

I know the pins are solidly connected because I am getting signal from my Max6675 module any help?

#include <max6675.h>
#include <SPI.h>
#include <Ethernet.h>
 
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(MY-IP);
 
// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(8080);

 int thermoDO = 3;
int thermoCS = 5;
int thermoCLK = 6;
int lightpin=8;
int light=7;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 2;
int gndPin = 4;

void setup() 
{
    pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  pinMode(lightpin,OUTPUT);
  pinMode(light,OUTPUT);
  Serial.begin(9600);
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  Serial.print(thermocouple.readCelsius());
 
}
 
void loop() 
{
 lightc();
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) 
        {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
    client.println("Refresh: 5");  // refresh the page automatically every 30 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
 
          
          float t = thermocouple.readCelsius();
          Serial.println(t);
 
          // from here we can enter our own HTML code to create the web page
          client.print("<head><title>Office Weather</title></head><body><h1>Office Temperature</h1><p>Temperature - ");
          client.print(t);
          client.print(" degrees Celsius</p>");
          if(int lightpin = HIGH) client.print("LIGHT ON");
          else client.print("LIGHT OFF");
          client.print("<p><em>Page refreshes every 5 seconds.</em></p></body></html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }

}

Comrade_Oscar: I know the pins are solidly connected because I am getting signal from my Max6675 module any help?

The GCC compiler would show you programming mistakes if you'd defined the pin numbers as constants in your program:

const int lightpin=8;
const int light=7;

You don't want the pin numbers to be changing during runtime, don't you?

So make the pin numbers "const" and watch what's happening when you try to compile your code!

Change this. Remove the int. That makes lightpin a local variable. And change the ‘=’ to ‘==’ for comparison instead of assignment.

if(int lightpin = HIGH) client.print("LIGHT ON");

SurferTim: Change this. Remove the int. That makes lightpin a local variable. And change the '=' to '==' for comparison instead of assignment.

if(int lightpin = HIGH) client.print("LIGHT ON");

And use digitalRead to get he pin states instead of trying to ompare the pin number to HIGH.