I wasn’t able to find anything helpful doing a search of the forum.
My setup is an Arduino Uno with a Color LCD Shield on top and nothing else. Eventually I’m trying to send HTML to a WiFly RN-XV, but for now I’m trying to just get the Color LCD Shield to display stuff and be able to also use the UART to send out lots of stuff over the serial communications. The problem I’m having is that when I am using lcd.setStr() the stuff I’m trying to send over the UART gets garbled up. Commenting out the function call for the function I’ve written (refreshLCD()) that contains lcd.setStr() fixes the UART problem.
Any help solving this problem is very much appreciated.
My code is below:
#include <ColorLCDShield.h>
#include <string.h>
#define B BLACK
#define F WHITE
LCDShield lcd;
char str1[17] = "0101010101010101";
char str2[17] = "1010101010101010";
char str3[17] = " Sunrise";
char str4[17] = "1010101010101010";
char str5[17] = "0101010101010101";
char str6[17] = "1010101010101010";
char str7[17] = "0101010101010101";
char str8[17] = "1010101010101010";
char str9[17] = "0101010101010101";
char tmp;
void setup()
{
lcd.init(EPSON); // This should only be init(EPSON) or init(PHILLIPS)
lcd.contrast(44);
lcd.clear(RED);
delay(500);
Serial.begin(9600);
} //void setup()
void loop()
{
refreshLCD();
ServePage();
delay(1000);
} //void loop()
void refreshLCD(void) {
lcd.clear(B);
delay(100);
lcd.setStr(str1,0,2,F,B);
lcd.setStr(str2,13,2,F,B);
lcd.setStr(str3,26,2,F,B);
lcd.setStr(str4,39,2,F,B);
lcd.setStr(str5,52,2,F,B);
lcd.setStr(str6,65,2,F,B);
lcd.setStr(str7,78,2,F,B);
lcd.setStr(str8,91,2,F,B);
lcd.setStr(str9,104,2,F,B);
delay(50);
} //void refreshLCD(void)
void HTML_print(char *data) {
Serial.println(data);
delay(30);
} //void HTML_print(char *data)
void ServePage(void) {
HTML_print("<html>");
HTML_print("<title>Rising Sun</title>");
HTML_print("<table>");
HTML_print("<tr>");
HTML_print("<td>");
HTML_print("<form action=\"\" method=\"post\">");
HTML_print("<fieldset>");
HTML_print("<p>Select Current Day:
");
HTML_print("<input type=\"radio\" name=\"#\" value=\"0\" /> Monday
");
HTML_print("<input type=\"radio\" name=\"#\" value=\"1\" /> Tuesday
");
HTML_print("<input type=\"radio\" name=\"#\" value=\"2\" /> Wednesday
");
HTML_print("<input type=\"radio\" name=\"#\" value=\"3\" /> Thursday
");
HTML_print("<input type=\"radio\" name=\"#\" value=\"4\" /> Friday
");
HTML_print("<input type=\"radio\" name=\"#\" value=\"5\" /> Saturday
");
HTML_print("<input type=\"radio\" name=\"#\" value=\"6\" /> Sunday</p>");
HTML_print("<p>Enter Current Time (HHMMSS):");
HTML_print("<input type=\"text\" name=\"%\" size=\"6\" /></p>");
HTML_print("<p>Select Alarm:");
HTML_print("<select name=\"~\">");
HTML_print("<option value=\"1\">1</option>");
HTML_print("<option value=\"2\">2</option>");
HTML_print("<option value=\"3\">3</option>");
HTML_print("<option value=\"4\">4</option>");
HTML_print("</select></p>");
HTML_print("<input type=\"radio\" name=\"^\" value=\"1\" checked/>Enable
");
HTML_print("<input type=\"radio\" name=\"^\" value=\"0\" />Disable</p>");
HTML_print("<p>Enter Alarm Time (HHMMSS): ");
HTML_print("<input type=\"text\" name=\"@\" size=\"6\" /></p>");
HTML_print("<p>Select Alarm Day(s):
");
HTML_print("<input type=\"checkbox\" name=\"!\" value=\"0\" /> Monday
");
HTML_print("<input type=\"checkbox\" name=\"!\" value=\"1\" /> Tuesday
");
HTML_print("<input type=\"checkbox\" name=\"!\" value=\"2\" /> Wednesday
");
HTML_print("<input type=\"checkbox\" name=\"!\" value=\"3\" /> Thursday
");
HTML_print("<input type=\"checkbox\" name=\"!\" value=\"4\" /> Friday
");
HTML_print("<input type=\"checkbox\" name=\"!\" value=\"5\" /> Saturday
");
HTML_print("<input type=\"checkbox\" name=\"!\" value=\"6\" /> Sunday</p>");
HTML_print("<input type=\"submit\" value=\"Go!!!\" />");
HTML_print("</fieldset>");
HTML_print("</form>");
HTML_print("</td>");
HTML_print("<td>");
HTML_print("<table>");
HTML_print("<tr><td><p>");
HTML_print("Time when page was loaded: ");
//display the time
HTML_print("</p></td></tr>");
for (int i = 1;i<=4;i++) {
HTML_print("<tr><td>");
//alarm info
HTML_print("<p>Alarm ");
Serial.print(i);
delay(30);
HTML_print("
");
//if( ) //if the alarm is enabled
HTML_print("Alarm Enabled
");
//else //if the alarm is not enabled
HTML_print("Alarm Disabled
");
HTML_print("Alarm Time: ");
HTML_print("</p></td></tr>");
} //for (int i = 1;i<=4;i++)
HTML_print("</td>");
HTML_print("</tr>");
HTML_print("</table>");
HTML_print("</html>");
delay(300);
Serial.print("$$");
delay(200);
HTML_print("close");
delay(30);
HTML_print("exit");
} //void ServePage(void)