Arduino YUN problemi serverweb Ethernet
ciao tutti, mi sapete dire per quale motivo non riesco fare girare qualsiasi skatch con impostazioni ethernet ad esempio questo
ho inserito ip e mac della scheda arduino, viene caricato in modo corretto, ma quando mi collego alla pagina web 192.168.0.107/sd/webserver non visualizzo nulla.....
dove sbaglio??
grazie tutti
buona serata
code: [select]
/*
web server
simple web server shows value of analog input pins.
using arduino wiznet ethernet shield.
circuit:
* ethernet shield attached pins 10, 11, 12, 13
* analog inputs attached pins a0 through a5 (optional)
created 18 dec 2009
david a. mellis
modified 9 apr 2012
tom igoe
*/
#include <spi.h>
#include <ethernet.h>
// enter mac address , ip address controller below.
// ip address dependent on local network:
byte mac[] = {
0x90, 0xa2, 0xda, 0xf8, 0x1d, 0x5b
};
ipaddress ip(192, 168, 1, 107);
// initialize ethernet server library
// ip address , port want use
// (port 80 default http):
ethernetserver server(80);
void setup() {
// open serial communications , wait port open:
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed leonardo only
}
// start ethernet connection , server:
ethernet.begin(mac, ip);
server.begin();
serial.print("server @ ");
serial.println(ethernet.localip());
}
void loop() {
// listen incoming clients
ethernetclient client = server.available();
if (client) {
serial.println("new client");
// http request ends blank line
boolean currentlineisblank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
serial.write(c);
// if you've gotten end of line (received newline
// character) , line blank, http request has ended,
// can send reply
if (c == '\n' && currentlineisblank) {
// send standard http response header
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println("connection: close"); // connection closed after completion of response
client.println("refresh: 5"); // refresh page automatically every 5 sec
client.println();
client.println("<!doctype html>");
client.println("<html>");
// output value of each analog input pin
(int analogchannel = 0; analogchannel < 6; analogchannel++) {
int sensorreading = analogread(analogchannel);
client.print("analog input ");
client.print(analogchannel);
client.print(" ");
client.print(sensorreading);
client.println("<br />");
}
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting new line
currentlineisblank = true;
}
else if (c != '\r') {
// you've gotten character on current line
currentlineisblank = false;
}
}
}
// give web browser time receive data
delay(1);
// close connection:
client.stop();
serial.println("client disconnected");
}
}
ho inserito ip e mac della scheda arduino, viene caricato in modo corretto, ma quando mi collego alla pagina web 192.168.0.107/sd/webserver non visualizzo nulla.....
dove sbaglio??
grazie tutti
buona serata
non credo tu possa usare la libreria "ethernet" ... quella è per gli shield ethernet, sulla yun la porta ethernet è connessa alla parte linux non alla parte arduino ...
devi studiarti la libreria "bridge" e le sue funzioni !
guglielmo
p.s. : ... auguri ...
devi studiarti la libreria "bridge" e le sue funzioni !
guglielmo
p.s. : ... auguri ...
Arduino Forum > International > Italiano > Software (Moderator: leo72) > Arduino YUN problemi serverweb Ethernet
arduino
Comments
Post a Comment