Aventuras y Desventuras de un hobbyist

Aventuras y Desventuras de un hobbyist....

Ejemplo simple de como usar la libreria Ethernet.h con Arduino

/*

Arduino and Ethernet

*/

#include
float voltage=0;
float sensor=0;
float celsius=0;
float fahrenheit=0;
float photocell=0;
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
192,168,0,77 }; // don't forget to change this IP address for your own
situation
Server server(80);
void setup()
{
Ethernet.begin(mac, ip);
server.begin();
}
void loop()
{
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
for (int loopy=0; loopy<10; sensor="analogRead(2);" voltage="((sensor*5000)/1024);" voltage="voltage-500;" celsius="voltage/10;" fahrenheit="((celsius*1.8)+32);" photocell="analogRead(5);" c ="=" current_line_is_blank =" true;" current_line_is_blank =" false;">






0 comentarios:

Publicar un comentario