Cannot Change - ARDUINO HTML Color code To Display Correctly

// HTML Code to print html web page
//Use photo cell to print html page WHEN The Room is Bright >> in yellow or PRINT The Room is now Dark >> in red
//Sense detection works fine but cannot seem to get the proper code to work to change the text to proper colors

client.println(“

INTERNET REMOTE CONTROL

“);//send first heading
client.println(”
”);
client.println("Analog input: "); //output some sample data to browser

sensorValue = analogRead(sensorPin);

// Print - when room is dark in red or print light in yellow when room has light

if (sensorValue < 250) {
client.println("The Room is now DARK "); //works
}
else {
//client.println("The Room is Bright "); //THIS LINE DOES NOT WORK - hangs my server

client.println(“The Room is Bright”); // HOWEVER THIS WORKS but no color change
}
client.println("


");
client.println("
");//some space between lines

Thanks for any help -Joe

Big strings like that consume the Arduino’s small amount of RAM very quickly. If you are using 1.0, wrap those things with “F()”. This will keep the strings out of RAM. If you aren’t using 1.0, search for the tutorial on PROGMEM.

Client.println(F(“stays in ROM”));

Also, you should wrap the color value in quotes.

James C4S, Thanks for the quick reply

  1. I recoded all colors with ‘xxxxxx’ - Single quotes and removed the # - this seems to have stabilized the web server.

  2. Your second pointer about saving ram…sounds like a good approach - i see the syntax but don’t quite follow, could you provide an example for the code below?

client.println("The Room is now BRIGHT "); //yellow

Joe

client.println( F("The Room is now BRIGHT ") );

Single quotes and removed the # - this seems to have stabilized the web server.

Except that the # should be required.

The web server needs to supply what the web browser needs to see. If the browser is expecting " double quotes, then they need to be supplied using the escape \ like below.

//use the \ slash to escape the " in the html
            client.println("<a href=\"/?on\" target=\"inlineframe\">ON</a>"); 
            client.println("<a href=\"/?off\" target=\"inlineframe\">OFF</a>");