Show Posts
Pages: [1]
1  Topics / Home Automation and Networked Objects / Re: Redirecting to file on Ethernet Shield SD card on: December 29, 2012, 11:56:48 pm
Thanks I converted the example code to how it fit my needs but now the site is stuck "transferring data" and the file will not load. Any ideas?

I'd assume that you would want to see my sketch so here it is:
Code:
#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 1, 24);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);
  Serial.print("Starting SD..");
  if(!SD.begin(4)) Serial.println("failed");
  else Serial.println("ok");
}
int b = 1;
void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    while (client.connected()) {
      digitalWrite(8, HIGH);
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        if (c == '\n')
        {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          File index = SD.open("index.html");
          if(index)
          {
            // read from the file until there's nothing else in it:
            while (index.available())
            {
              client.write(index.read());
            }
            index.close();
          }
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    digitalWrite(8, LOW);
    Serial.println("client disonnected");
  }
}
2  Topics / Home Automation and Networked Objects / Redirecting to file on Ethernet Shield SD card on: December 28, 2012, 04:55:17 pm
I have a web page I want to host on my Arduino w/ Ethernet Shield but I don't want to have to put in every line of the markup into the sketch. There are also a couple of files that I can't put into the sketch. Is there anyway to show the browser the files on the shield's SD card, so that it can use them?
3  Products / Arduino Due / Re: Using a USB keyboard via USB OTG on Due on: December 28, 2012, 11:29:24 am
I found the USBHost page this is what I needed.
http://arduino.cc/en/Reference/USBHost
4  Products / Arduino Due / Using a USB keyboard via USB OTG on Due on: December 28, 2012, 11:22:42 am
I recently got an Arduino Due and after reading that it has USB OTG capabilities I would like to use them. I have a USB keyboard and I would like to get input from it but I cannot find any documentation on how to do it. Are there any libraries or any way to get input from a USB device via a USB OTG cable? Also I assume I would use the Native USB Port, correct?
Pages: [1]