i want to read text from text file toaurduino and i want to display it on lcd.
its not showing anything on lcd
its not showing any error also
if anyone did like this kind of project help me for modifying this code.
#include <SPI.h>
#include <Ethernet.h>
#include "rgb_lcd.h"
#include <Wire.h>
rgb_lcd lcd;
byte mac[] = { 0x98, 0x4F, 0xEE,0x01, 0x65, 0x4E };
IPAddress ip(192,168,19,170);
char server[] = "192.168.19.171"; // name address for LiyanageGroup (using DNS)
char inString[32]; // string for incoming serial data
int stringPos = 0; // string index counter
boolean startRead = false; // is reading?
// Set the static IP address to use if the DHCP fails to assign
EthernetClient client;
//LiquidCrystal lcd(2, A0, A1, A2, A3, A4, A5);
void setup() {
Serial.begin(9600);
while (!Serial) {
}
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
Ethernet.begin(mac, ip);
}
ConnectAndRead();
lcd.begin(16,2);
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print(" Liyanage Group");
}
void ConnectAndRead(){
delay(5000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /read_data.txt HTTP/1.1");
client.println("Host:192.168.19.171");
client.println("Connection: close");
client.println();
}
else {
Serial.println("connection failed");
}
}
String ReadPage(){
stringPos = 0;
memset( &inString, 0, 32 ); //clear inString memory
while(client.connected()){
if (client.available()) {
char c = client.read();
if (c == '
) { //'<' is our begining character
startRead = true; //Ready to start reading the part
}else if(startRead){
if(c != '#'){ //'>' is our ending character
inString[stringPos] = c;
stringPos ++;
}else{
//got what we need here! We can disconnect now
startRead = false;
client.stop();
client.flush();
return inString;
}
}
}
}
}
void loop()
{
if(!client.connected()){
client.stop();
ConnectAndRead();
}
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Web Value : "); // change this text to whatever you like. keep it clean.
lcd.print(ReadPage()); // change this text to whatever you like. keep it clean.
delay(50);
}