Show Posts
Pages: [1] 2 3
1  Using Arduino / Networking, Protocols, and Devices / Re: Control LED whit htm page and Ethernet Shield. on: May 21, 2013, 09:00:19 am
Quote
Thanks for the answer, but is not posible to do that whitout JavaScript?

Well, it depends on what the "that" you refer to is. You talking about javascript sliders, or just downloading files from the SD card?
I refer to send the string, is posible to do whit html using a button?
2  Using Arduino / Networking, Protocols, and Devices / Re: Control LED whit htm page and Ethernet Shield. on: May 20, 2013, 10:33:39 pm
Servo control test code that down loads the files to generate a servo slider control on a web page. You could do similar by putting your current html control page file on the SD card, then downloading it.

Code:
//zoomkat 1/26/13
//SD server slider test code
//open serial monitor to see what the arduino receives
//address will look like http://192.168.1.102:84/servosld.htm when submited
//for use with W5100 based ethernet shields
//put the servosld.htm, slider.js, bluev_sl.gif,
//and bluev_bg.gif on the SD card
//files at http://web.comporium.net/~shb/servoslider.htm page


#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>

#include <Servo.h>
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo
Servo myservoe, myservof, myservog;
String readString, pos;

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = {
  192, 168, 1, 102 }; // ip in lan
byte gateway[] = {
  192, 168, 1, 1 }; // internet access via router
byte subnet[] = {
  255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

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

void setup(){

  Serial.begin(9600);

  // disable w5100 while setting up SD
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);
  Serial.print("Starting SD..");
  if(!SD.begin(4)) Serial.println("failed");
  else Serial.println("ok");

  Ethernet.begin(mac, ip, gateway, gateway, subnet);

  //delay(2000);
  server.begin();
  Serial.println("Ready");
 
  myservoa.attach(2);  //the pin for the servoa control
  myservob.attach(3);  //the pin for the servob control
  myservoc.attach(5);  //the pin for the servoc control
  myservod.attach(6);  //the pin for the servod control
  myservoe.attach(7);  //the pin for the servoa control
  myservof.attach(8);  //the pin for the servob control
  myservog.attach(9);  //the pin for the servoc control
  //myservoh.attach(10);  //the pin for the servod control

}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {
          //store characters to string
          readString += c;
          //Serial.print(c);
        }
        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging
         
         //select proper header for file to be sent to browser
         
          client.println("HTTP/1.1 200 OK"); //send new page
          if(readString.indexOf("servosld") >=0) {
          client.println("Content-Type: text/html");
          client.println(); }

          if(readString.indexOf("slider") >=0) {
          client.println("Content-Type: application/x-javascript");
          client.println(); }
         
          if(readString.indexOf("bluev") >=0) {
          client.println("Content-Type: image/gif");
          client.println(); }
         
          //select file to send to browser
          if(readString.indexOf("servosld") >=0) {
            File myFile = SD.open("SERVOSLD.HTM");
            if (myFile) {
              while (myFile.available()) {
                client.write(myFile.read());
              }
              myFile.close();
            }
          }

          if(readString.indexOf("slider") >=0) {
            File myFile = SD.open("slider.js");
            if (myFile) {
              while (myFile.available()) {
                client.write(myFile.read());
              }
              myFile.close();
            }
          }

          if(readString.indexOf("bluev_sl") >=0) {
            File myFile = SD.open("bluev_sl.gif");
            if (myFile) {
              while (myFile.available()) {
                client.write(myFile.read());
              }
              myFile.close();
            }
          }

          if(readString.indexOf("bluev_bg") >=0) {
            File myFile = SD.open("bluev_bg.gif");
            if (myFile) {
              while (myFile.available()) {
                client.write(myFile.read());
              }
              myFile.close();
            }
          }

          delay(1);
          //stopping client
          client.stop();

          //process GET string request from client and and position servo
         
          pos = readString.substring(8, 12); //get the first four characters         
          //Serial.println(pos);
          int n = pos.toInt();  //convert readString into a number   
          Serial.println(n);
          Serial.println();
         
          if(readString.indexOf("?0") >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf("?1") >0) myservob.writeMicroseconds(n);
          if(readString.indexOf("?2") >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf("?3") >0) myservod.writeMicroseconds(n);
          if(readString.indexOf("?4") >0) myservoe.writeMicroseconds(n);
          if(readString.indexOf("?5") >0) myservof.writeMicroseconds(n);
          if(readString.indexOf("?6") >0) myservog.writeMicroseconds(n);
          //only seven servo pins, so back to myservoa for testing
          if(readString.indexOf("?7") >0) myservoa.writeMicroseconds(n);

          //clearing string for next read
          readString="";
          pos="";
        }
      }
    }
  }
}

Thanks for the answer, but is not posible to do that whitout JavaScript?
3  Using Arduino / Networking, Protocols, and Devices / Control LED whit htm page and Ethernet Shield. on: May 20, 2013, 11:24:01 am
Hi, i want to control a led whit arduino ethernet shield W5100 and htm pages loaded from the sd card, i can control it whit diferent pages, for example i have the index, then one link to other page, and put the led code to turn on when i request that page, but this isnt good, because i will need to do one page for each led i will control, could you tell me if there is a way to do this without having to load a new page? thanks.
4  Using Arduino / Networking, Protocols, and Devices / Re: Load pages from SD (W5100) on: May 14, 2013, 09:55:59 am
I tried removing the serial monitor and the problem still.
5  Using Arduino / Networking, Protocols, and Devices / Re: Load pages from SD (W5100) on: May 12, 2013, 10:01:11 am
You have a Ethernet, SD and String class in a Arduino Uno, that uses a lot of ram.

Is it an existing example ? Can you give a link to it ?

In the sketch, every ethernet byte is echoed to the serial monitor, which is only 9600 baud. Could you try without the "Serial.print(c);" ?
Thanks for answer, im using a Arduino Mega 2560, and this is the link of the code http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-web-server-links/, i will try the code whitout the serial print and edit whit the result.
6  Using Arduino / Networking, Protocols, and Devices / Load pages from SD (W5100) on: May 11, 2013, 04:17:15 pm
Hi, i want to do a webserver whit 5 pages, i used a example code and it works, i can enter to the main page then open other, but the problem is that after open pages for a few times it start to load slow or dont open the page, then start to work correctly again,this always happen andt i dont know if is problem whit the code or my arduino/ethernet shield, i would apreciate if someone can help me to know what happen, thanks.
Code:
Quote
/*--------------------------------------------------------------
  Program:      eth_websrv_SD_link

  Description:  Arduino web server that serves up a basic web
                page that links to a second page. Clicking the
                link will open the second page. The second page
                links back to the first page.
 
  Hardware:     Arduino Uno and official Arduino Ethernet
                shield. Should work with other Arduinos and
                compatible Ethernet shields.
                2Gb micro SD card formatted FAT16
               
  Software:     Developed using Arduino 1.0.3 software
                Should be compatible with Arduino 1.0 +
               
                Requires index.htm and page2.htm to be on the
                micro SD card in the Ethernet shield micro
                SD card socket.
 
  References:   - WebServer example by David A. Mellis and
                  modified by Tom Igoe
                - SD card examples by David A. Mellis and
                  Tom Igoe
                - Ethernet library documentation:
                  http://arduino.cc/en/Reference/Ethernet
                - SD Card library documentation:
                  http://arduino.cc/en/Reference/SD

  Date:         2 March 2013
 
  Author:       W.A. Smith, http://startingelectronics.com
--------------------------------------------------------------*/

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 0, 0, 20); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80

File webFile;

String HTTP_req = "";     // stores the received HTTP request

void setup()
{
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
    Serial.begin(9600);       // for debugging
   
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
}

void loop()
{
    EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                HTTP_req += c;          // save HTTP request character
                Serial.print(c);    // print HTTP request character to serial monitor
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connnection: close");
                    client.println();
                    // send web page
                    if ((HTTP_req.indexOf("GET / ") > -1)
                                 || (HTTP_req.indexOf("GET /index.htm") > -1)) {
                        webFile = SD.open("index.htm");        // open web page file
                    }
                    else if (HTTP_req.indexOf("GET /page2.htm") > -1) {
                        webFile = SD.open("page2.htm");        // open web page file
                    }
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }
                    HTTP_req = "";  // empty the string
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                }
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
}
7  Using Arduino / Networking, Protocols, and Devices / Re: Problems whit Ethernet Shield and SD on: May 07, 2013, 10:54:28 am
I might have missed something but did you forget to post your code?
I used the example of this tutorial to load the pages from the sd http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/SD-card-web-server-image/ .
8  Using Arduino / Networking, Protocols, and Devices / Problems whit Ethernet Shield and SD on: May 06, 2013, 10:19:43 pm
Hi, im testing a web server that load .htm pages from a micro sd card using a Arduino Mega and Ethernet Shield w5100, it works, but sometines take a very long time to load or the page dont load, when my wi-fi signal is low this happen more, i tried using the web server like the arduino examples, whit the html code in the arduino's code and i dont have the problem, i would apreciate if something can help me to know what happen, i think can be a problem reading the files from the micro sd but im not sure, thanks.
9  Using Arduino / Networking, Protocols, and Devices / Re: Links whit Ethernet Shield on: May 02, 2013, 07:09:20 pm
It sounds like you need to learn up on how to make an HTML page with buttons in it that does what you want.

It would be a good idea to get the HTML page working in standalone form in the browser before integrating the HTML into your arduino code.  That way you are debugging less at one time.

Good luck with your project,

-br

Thanks for your answer, but i think i didnt explain well my problem, in html to do what I want i should have some .html files whit the code, and when i press a button do that botton send me to the html file, but how to do that in arduino.
10  Using Arduino / Networking, Protocols, and Devices / Links whit Ethernet Shield on: May 02, 2013, 06:23:30 pm
Hi, im making a proyect whit ethernet shield and a iphone, and i want to do a user interface to control the arduino, but i need to do links to open whit buttons, for example in the first page a button, if i click  the button it send me to arduinourl/button and show other page, but i dont know if this is possible i would appreciate if anyone can help me whit this.
11  International / Proyectos / Links con Ethernet Shield on: May 01, 2013, 01:00:04 pm
Hola, estoy empezando con el ethernet shield y tengo una duda, es posible tener diferentes url con un solo arduino y cada una muestre cosas diferentes? por ejemplo 192.xxx.x.xx seria la pagina principal, y al dar click un boton que mande a 192.xxx.x.xx/boton y aparesca otra cosa, he estado investigando pero no he encontrado nada al respecto, agradecería si alguien me puede decir si es posible, gracias de antemano
12  Using Arduino / Networking, Protocols, and Devices / Show images whitEthernet Shield. on: April 30, 2013, 12:37:15 am
He, i want to do a user inteface for iphone whit a ethernet sheild, but show only text dont look very good, i tried to load images using this code:
Code:
client.println ("<img src = 'http://imageurl.com/image.png''>");
but it didnt work, i would appreciate if someone can tell me how i can show images whit the ethernet shilld server, thanks for afterhand.
13  Using Arduino / Project Guidance / Re: Run Arduino Mega + Ethernet Shield 24/7 on: April 09, 2013, 09:18:18 pm
Why wouldn't it?
I dont know, just want to know if i can have a problem whit that before start the proyect.
14  Using Arduino / Project Guidance / Run Arduino Mega + Ethernet Shield 24/7 on: April 09, 2013, 09:10:09 pm
Hi, im working in a proyect that need a arduino mega whit ethernet shield working all the day, but im not sure if i can have problems if the arduino work for a long time, I would appreciate if someone can give some recommendation about this.
15  Using Arduino / Networking, Protocols, and Devices / Re: Problems whit Ethernet Shield (W5100) on: April 02, 2013, 08:37:57 pm
That ethernet shield does not have the ICSP header on the bottom, so you will need to jumper a few pins to connect the SPI data lines. Use a few short jumper wires to connect these pins:
shield   Mega
D11  ->  D51
D12  ->  D50
D13  ->  D52

Leave D10 where it is to maintain compatibility with the ethernet library.

Thanks, that was the problem, but i have another quiestion, i can store image files in a SD and open it whit HTML code whit this ethernet module? because i want to do a server and i need to use images in the design.
Pages: [1] 2 3