Hi everyone have a big problem to solve,
so i have server(spare laptop runing ubuntu server 10.04) running on my local lan which ip is 192.168.1.9(an no-ip address islmasss.hopto.org) where i uploaded tank.html but if i accsess my page using lmasss.hopo.org and try to move forward in responce from tank window i get error that my page 192.168.1.14(wifly) is not accsesable.question is somhow to do so it still will send data from lmasss.hopo.org to 192.168.1.14 so i can control tank from outside of my lan?
Html page
<html>
<head>
<title>Arduino wi-fi tank</title>
<style>
html,body{font:normal 14px arial,helvetica;}
#content { width:600px;margin:100px auto;}
#response { font-family:Courier;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="content">
<table>
<tr><td> </td><td><button rel="n">Fwd</button></td><td> </td></tr>
<tr><td><button rel="w">Left</button></td><td> </td><td><button rel="e">Right</button></td></tr>
<tr><td> </td><td><button rel="s">Back</button></td><td> </td></tr>
</table>
<div style="margin-top:20px;border-top:1px solid #ccc;padding-top:10px;">
<h3>Response from tank</h3>
<div id="response">
<iframe id="tank"></iframe>
</div>
</div>
</div>
<script>
$("button").click(function() {
//$("#response").load("http://192.168.1.14/?dir=" + $(this).attr("rel"));
$("#tank").attr("src", "http://192.168.1.14/?dir=" + $(this).attr("rel"));
});
</script>
</body>
</html>
arduino code
/*
* 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);
long startTime;
Server server(80);
// set the output pins
int baseMotorEnablePin = 5;
int baseMotorPin1 = 6;
int baseMotorPin2 = 7;
int shoulderMotorEnablePin = 14;
int shoulderMotorPin1 = 15;
int shoulderMotorPin2 = 16;
///////////////////////////////
void setup() {
WiFly.begin();
if (!WiFly.join(ssid, passphrase, WEP_MODE)) {
while (1) {
// Hang on failure.
}
}
//set the SN754410 pins as outputs:
pinMode(baseMotorPin1, OUTPUT);
pinMode(baseMotorPin2, OUTPUT);
pinMode(baseMotorEnablePin, OUTPUT);
digitalWrite(baseMotorEnablePin, HIGH);
pinMode(shoulderMotorPin1, OUTPUT);
pinMode(shoulderMotorPin2, OUTPUT);
pinMode(shoulderMotorEnablePin, OUTPUT);
digitalWrite(shoulderMotorEnablePin, HIGH);
//++++++++++++++++++++++++++++++++++++++++++++++//
Serial.begin(9600);
Serial.print("IP: ");
Serial.println(WiFly.ip());
server.begin();
}
void loop() {
if(startTime!=0 && millis()-startTime>1500){
moveStop();
}
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
String cmd = "";
int i = 0;
while (client.connected()) {
if (client.available()) {
char c = client.read();
cmd += c;
if (cmd == "GET /?dir=n")
{
//Serial.println("north");
client.println("moving forward");
moveForward();
delay(100);
client.stop();
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
}
else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
delay(100);
client.stop();
}
}
void moveForward(){
startTime=millis();
digitalWrite(baseMotorPin1, LOW);
digitalWrite(baseMotorPin2, HIGH);
digitalWrite(shoulderMotorPin1, LOW);
digitalWrite(shoulderMotorPin2, HIGH);
}
void moveStop(){
startTime=0;
digitalWrite(baseMotorPin1, LOW);
digitalWrite(baseMotorPin2, LOW);
digitalWrite(shoulderMotorPin1, LOW);
digitalWrite(shoulderMotorPin2, LOW);
}