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

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
How to control a servo motor with Windows Remote Arduino?
Set baud rate to esp8266 at 9600
Arduino AC Dimmer - serial communication lost due to interrupt

Categories

HOME
twitter
testng
azure-data-factory
include
read-eval-print-loop
kalman-filter
ip
retrofit
fingerprint
opengl-es-2.0
mouse
append
android-youtube-api
medical
primary-key
gnupg
ssl-client-authentication
row
numeral.js
handsontable
qt-creator
designer
tostring
pugjs
invantive-sql
http-status-code-504
lucene.net
cx-freeze
orleans
facebook-instant-articles
extjs5
zurb-foundation-6
format-specifiers
vlsi
chromebook
user-interaction
tooltipster
spring-mybatis
elasticsearch-net
google-cloud-nl
titanium-mobile
rotational-matrices
stacked
serverside-rendering
occlusion
webix-treetable
user-controls
nand2tetris
fakeiteasy
turbogears
vao
upstart
nstextview
jxcore
font-size
sybase-asa
spring-mongodb
chord-diagram
xcb
ableton-live
color-picker
gridpane
mathematica-frontend
mongocsharpdriver
photobucket
historian
content-length
twirl
splash
sortedlist
streambase
truevault
javax.mail
geonetwork
pick
coldbox
neolane
wp-query
rebol3
xceed-datagrid
inbox
jmapviewer
quartz-graphics
eclipse-memory-analyzer
buster.js
bluepill
multipage
twrequest
getmessage
fireworks
external-accessory
tomcat-valve
rfc1123
appendto
ecl
grid-system

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App