Hi all,
I using tutorial from
http://www.arduino.cc/cgi-bin/yabb2/YaB … 78347111/0
Got nice UI (page 7 to 9) website lods from my server nicely show current led statuses but unfotianatly Trying to turn led on or off not working corectly.
If i press led 3 it will hang,then i press led 8 it will turn it on,and if i will press led 8 again its hang again, but after led 3 pressed it turning it on.And so on and on each time tu turn le on or off need press other led first than you led which you want to press.
Hope its understandibe my writing and problem
I using WiFly Shield code library alpha 1 release and arduino 2009
my Arduino code is
/*
* Web Server
*
* (Based on Ethernet's WebServer Example)
*
* A simple web server that shows the value of the analog input pins.
*/
#include "WiFly.h"
#include "Credentials.h"
#include <WString.h>
String readString = String(100);
Server server(80);
void setup() {
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
while (1) {
// Hang on failure.
}
}
//pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Serial.print("IP: ");
Serial.println(WiFly.ip());
pinMode(8, OUTPUT); digitalWrite(8, LOW); // led 8
pinMode(3, OUTPUT); digitalWrite(3, LOW); // led 3
server.begin();
}
void loop(){
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 100){
readString.append(c);
}
if (c == '\n') {
if(readString.contains("led8")){
toggle(8);
} ///else
if(readString.contains("led3")) {
toggle(3);
}
client.println("<html><center>");
client.println("Light 3
");
if (digitalRead(3) == LOW){
client.println("<img src='http://192.168.1.9/images/lightoff.png'>");
} else if (digitalRead(3) == HIGH){
client.println("<img src='http://192.168.1.9/images/lighton.png'>");
}
client.println("<form method='get'><input type=submit name=led3 value=toggle></form>");
readString="";
client.println("Light 8
");
if (digitalRead(8) == LOW){
client.println("<img src='http://192.168.1.9/images/lightoff.png'>");
} else if (digitalRead(8) == HIGH){
client.println("<img src='http://192.168.1.9/images/lighton.png'>");
}
client.println("<form method='get'><input type=submit name=led8 value=toggle></form>");
client.println("</center></html>");
readString="";
delay(10);
client.stop();
}
}
}
}
}
int toggle(int pin){
if(digitalRead(pin) == LOW){
digitalWrite(pin, HIGH);
} else {
digitalWrite(pin, LOW);
}
}
And PHP code is
<html>
<head>
<title>Motor Control</title>
<script type="text/JavaScript" src="scripts/jquery.js"></script>
<script type="text/JavaScript" src="scripts/js/jquery-ui-1.8.2.custom.min.js"></script>
<link type="text/css" href="scripts/css/start/jquery-ui-1.8.2.custom.css" rel="stylesheet" />
<script type="text/javascript">
//accordion code set to mouseover and no autoheight
$(function() {
$("#accordion").accordion({
event: "mouseover",
autoHeight: false
});
});
</script>
</head>
<body BGcolor='grey'>
<div id=accordion style="width:250px;">
<h3><a href="#">Control</a></h3>
<div bgcolor='grey'>
<iframe width='150' height='350' allowtransparency=true frameborder=0 scrolling=none src="http://192.168.1.14"></iframe>
</div>
</div>
</body>
</html>
all setup is on my network with ubuntu 10.04 server .