arduino-uno


I cannot solve my arduino program error


My project is about unlock and lock door through web server. but I have some kind a problem with my arduino program. I am new with arduino program, this is my program.
Can help me to solve this problem?
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modifie
*/
#include<SPI.h>
#include<Ethernet_v2.h>
#include<SD.h>
#define REQ_BUF_SZ 60
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
#if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io
;
#else
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
#endif
IPAddress ip(192,168,1,177);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
File webFile;
char HTTP_req[REQ_BUF_SZ] = {0};
char req_index = 0;
boolean LED_state[2] = {0};
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial)
{
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Initializing SD card........");
if(!SD.begin(4)){
Serial.println("Error-SD card initialized");
return;
}
Serial.println("Success-Found cuba.htm file");
pinMode(8, OUTPUT);
// start the Ethernet connection and the server:
#if defined(WIZ550io_WITH_MACADDRESS)
Ethernet.begin(ip);
#else
Ethernet.begin(mac, ip);
#endif
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
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();
if (req_index < (REQ_BUF_SZ - 1)) {
HTTP_req[req_index] = c; // save HTTP request character
req_index++;
}
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
if (StrContains(HTTP_req, "ajax_inputs")) {
client.println("Content-Type: text/html");
client.println("Connection: Keep-alive");// the connection will be closed after completion of the response
client.println();
SetDNS();
XML_response(client);
}
else{
client.println("Content-Type: text/html");
client.println("Connection: keep-alive");
client.println();
webFile=SD.open("cuba.htm");
if(webFile){
while(webFile.available()){
client.write(webFile.read());
}
webFile.close();
}
}
Serial.print(HTTP_req);
req_index = 0;
StrClear(HTTP_req, REQ_BUF_SZ);
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();
}
}
void SetDNS(void)
{
// LED 1 (pin 6)
if (StrContains(HTTP_req, "DNS=1")) {
DNS_state[0] = 1; // save LED state
digitalWrite(8, HIGH);
}
else if (StrContains(HTTP_req, "DNS=0")) {
DNS_state[0] = 0; // save LED state
digitalWrite(8, LOW);
}
}
void XML_response(EthernetClient cl)
{
int analog_val; // stores value read from analog inputs
int count; // used by 'for' loops
int sw_arr[] = {2, 3}; // pins interfaced to switches
cl.print("<?xml version = \"1.0\" ?>");
cl.print("<inputs>");
cl.print("<DNS>");
if (DNS_state[1]) {
cl.print("on");
}
else {
cl.print("off");
}
cl.println("</DNS>");
cl.print("</inputs>");
}
// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
for (int i = 0; i < length; i++) {
str[i] = 0;
}
}
// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
char found = 0;
char index = 0;
char len;
len = strlen(str);
if (strlen(sfind) > len) {
return 0;
}
while (index < len) {
if (str[index] == sfind[found]) {
found++;
if (strlen(sfind) == found) {
return 1;
}
}
else {
found = 0;
}
index++;
}
return 0;
}
For your information this is original LED program but I change it.
This is the error when I compiled my program
WebServer.ino: In function 'void loop()':
WebServer:96: error: 'StrContains' was not declared in this scope
WebServer:101: error: 'SetDNS' was not declared in this scope
WebServer:102: error: 'XML_response' was not declared in this scope
WebServer:118: error: 'StrClear' was not declared in this scope
WebServer.ino: In function 'void SetDNS()':
WebServer:142: error: 'StrContains' was not declared in this scope
WebServer:143: error: 'DNS_state' was not declared in this scope
WebServer:147: error: 'DNS_state' was not declared in this scope
WebServer.ino: In function 'void XML_response(EthernetClient)':
WebServer:162: error: 'DNS_state' was not declared in this scope
'StrContains' was not declared in this scope
that all thank you for your concern
You have to declare functions before you call it.
Try to move the loop function at the bottom of your file.

Related Links

Arduino not displaying results
Python ImportError: No module named yahoo_finance
Can I take solar panel's output as an input to Arduino
I cannot find UID of my Arduino
Arduino Program Reset Bug
arduino uno R3 input pins with gsm shield
Light weight machine to machine communication with Arduino
Interfacing RM5 evolution coin acceptor with arduino
Arduino-ESP8266 Sending URL from a client browser connected to the esp8266 AP and receiving the entered URL in the arduino board
Need explanations about a code relative to MPU6050
Arduino Programmer only works after unlugging and plugging back in
How do I communicate between Arduino board and Intel Edison Arduino board using XBee S2?
I cannot solve my arduino program error
2.4 inch TFT LCD SPFD5408 with Arduino Uno - touch not working
DAC0808 doesn't want tranfer to analog
Trouble in programming arduino with esp8266

Categories

HOME
bluetooth
debugging
ngrx
heroku
hashmap
android-4.4-kitkat
graphql
electronics
frameworks
jxls
alpha
directx
node-notifier
webrequest
add
primary-key
midi
windows-azure-storage
orchardcms
dynamics-crm-online
worldwind
reactive-cocoa
code-review
google-cloud-speech
swingx
centos6.5
phpfox
filezilla
social-media
fluentvalidation
publish
kendo-datasource
perlin-noise
adobe-premiere
space-complexity
espeak
code-search-engine
c11
twitch
webix-treetable
ssjs
splice
cookiecutter-django
jvm-languages
glew
firebase-admin
mime
convertapi
jedis
clean-architecture
git-diff
lowpass-filter
directory-structure
libusb-win32
ifs
jspdf-autotable
webdriverjs
xcb
elements
azure-virtual-network
mikroc
qpid
make-install
bluemix-app-scan
ptrace
freedesktop.org
mutation-observers
kcachegrind
embedded-code
android-listview
c3
tablelayout
android-imagebutton
internet-connection
openexr
yorick
valueconverter
resty-gwt
bulkloader
file-locking
excel-2003
eclipse-memory-analyzer
sharp-repository
simba
bitsharp
trusted
rdoc
netbeans-6.9
custom-backend
gwt-ext
external-accessory
floating
icanhaz.js
vc90
scripting-languages
3gp

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App