refresh iframe problemen met button

Arduino shields
Berichten: 1
Geregistreerd: 17 Nov 2016, 16:55

refresh iframe problemen met button

Berichtdoor drek123 » 19 Jan 2017, 10:34

Beste,
Ik ben aan het leren hoe een arduino programma werkt op een ethernet shield , ik met de links kan ik het iframe refreshen naar bv 1 s 10 s enz
maar nu zou ik dit met een button willen doen en dit lukt maar niet van zodra ik de button indruk krijg ik alleen het iframe met de nieuwe refresh
rate maar van de index page is niets meer te zien, ik heb er al een hele tijd op gezocht maar zie niet wat ik mis doe,
kan iemand mij hiermee helpen ? META-REFRESH, SINGLE-STOP ,FAST-DATA, SLOW-DATA die werken met de knop Fast alleen het iframe
in de bijlagen kan je zien hoe het scher eruit ziet als ik gebruik maak van de url's FAST-DATA etc. en 2de bijlage als ik op de button Fast druk

Alvast al hartelijk dank


onderstaande de code:
cpp code
#include <Arduino.h>
#define Echo_ingangsPin 7 // ingang echo pin
#define Trigger_uitgangsPin 8 // trigger uitgangspin
int maximumRange = 300;
int minimumRange = 2;
#include <EasyButton.h>
// zoomkat's meta refresh data frame test page 5/25/13
// use http://192.168.1.102:84 in your brouser for main page
// http://192.168.1.102:84/data static data page
// http://192.168.1.102:84/datastart meta refresh data page
// for use with W5100 based ethernet shields
// set the refresh rate to 0 for fastest update
// use STOP for single data updates

#include <SPI.h>
#include <Ethernet2.h>
long afstand;
long duur;
const int analogInPin0 = A0;
const int analogInPin1 = A1;
const int analogInPin2 = A2;
const int analogInPin3 = A3;
const int analogInPin4 = A4;
const int analogInPin5 = A5;

byte mac[] = { 0x90, 0xA2, 0xDA, 0x10, 0xB4, 0x00}; //physical mac address
byte ip[] = { 10, 33, 211, 179}; // arduino ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
unsigned long int x=0; //set refresh counter to 0
String readString;

//////////////////////

void setup(){
pinMode(Trigger_uitgangsPin, OUTPUT);
pinMode(Echo_ingangsPin, INPUT);
Serial.begin(9600);
// disable SD SPI if memory card in the uSD slot
pinMode(4,OUTPUT);
digitalWrite(4,HIGH);

Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
Serial.println("meta refresh data frame test 5/25/13"); // so I can keep track of what is loaded
}
/////////////////////////////////////////////////
void loop(){
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 100) {
readString += c;
}
//check if HTTP request has ended
if (c == '\n') {

//check get atring received
Serial.println(readString);

//output HTML data header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();

//generate data page
if(readString.indexOf("data") >0) { //checks for "data" page

x=x+1; //page upload counter
client.print("<HTML><HEAD>");

//meta-refresh page every 1 seconds if "datastart" page
if(readString.indexOf("datastart") >0) client.print("<meta http-equiv='refresh' content='1'>");

//meta-refresh 0 for fast data
if(readString.indexOf("datafast") >0) client.print("<meta http-equiv='refresh' content='0'>");

//meta-refresh 10 for slowdata
if(readString.indexOf("slowdata") >0) client.print("<meta http-equiv='refresh' content='10'>");

client.print("<title>Zoomkat's meta-refresh test</title></head><BODY><br>");

client.print("page refresh number: ");
client.print(x); //current refresh count
client.print("<br><br>");
// nieuw stuk
// pulse van 10µs die word gestuurd
digitalWrite(Trigger_uitgangsPin, HIGH);
delayMicroseconds(10);
digitalWrite(Trigger_uitgangsPin, LOW);
duur = pulseIn(Echo_ingangsPin, HIGH);

afstand = duur/58.2;
//output the value of each analog input pin
if (afstand >= maximumRange || afstand <= minimumRange);

client.print("afstand: ");
client.print(afstand);


client.print("<br>analog input0 is: ");
client.print(analogRead(analogInPin0));

client.print("<br>analog input1 is: ");
client.print(analogRead(analogInPin1));

client.print("<br>analog input2 is: ");
client.print(analogRead(analogInPin2));

client.print("<br>analog input3 is: ");
client.print(analogRead(analogInPin3));

client.print("<br>analog input4 is: ");
client.print(analogRead(analogInPin4));

client.print("<br>analog input5 is: ");
client.print(analogRead(analogInPin5));
client.println("<br></BODY></HTML>");
}
//generate main page with iframe
else
{
client.print("<HTML><HEAD><TITLE>Read sensors online</TITLE></HEAD>");

client.print("Data input online</a><BR>");


client.print("<body style=background:#80BFFF>"); // background page
client.print("<BR><BR>Arduino analog input data frame:<BR>");
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//client.print("<input type=submit value=Fast style=width:100px;height:45px onClick= location.href='/datafast' target= 'DataBox' >"); // button
client.print("<input type=submit value=Fast style=width:100px;height:45px onClick= location.href=location.href='/datafast' name='DataBox' > ");
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// client.println("<a href=\"/?on1\" target=\"inlineframe\">ON</a> client.print("<meta http-equiv='refresh' content='10'>");

client.print("&nbsp;&nbsp;<a href='/datastart' target='DataBox' title=''aa''>META-REFRESH</a>");



client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='/data' target='DataBox' title=''bb''>SINGLE-STOP</a>");
client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='/datafast' target='DataBox' title=''cc''>FAST-DATA</a>");
client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='/slowdata' target='DataBox' title=''dd''>SLOW-DATA</a><BR>");

client.print("<iframe src='/data' width='350' height='500' style='background-color: #f00 ;'} ; name='DataBox'>");// background iframe
client.print("</iframe></HTML>");
}
delay(100);

client.stop();

readString="";
}
}
}
}
}

Advertisement

Terug naar Shields

Wie is er online?

Gebruikers in dit forum: Bing [Bot], Google [Bot] en 1 gast