Show Posts
Pages: [1] 2
1  Using Arduino / Networking, Protocols, and Devices / Re: Bluetooth Module TX HELP on: April 01, 2012, 07:02:06 pm
you might need to hook the BT to the other soft serial if your using a terminal program to read from the arduino.  also you dont seem to be reading the tx line into the arduino sketch code.
2  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 06:56:19 pm
has to be this guys code.  i finally got it to display the webpage and the function of it doesnt work.  off to learn how to host a website on the arduino i guess.  thanks everyone.
3  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 05:58:53 pm
ethernet address printer works and i get my local address from the net work
4  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 05:20:02 pm
thats what i have now.  going to see if it works now.
5  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 05:04:18 pm
downloaded arduino software again replaced the ethernet library and i am going to see if i can get the example printer to work.
6  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 05:00:27 pm
yes the code i copied is straight from the ethernet address printer example sketch.  the one that would not compile.
7  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 04:54:27 pm
thats what is in the one i have that i opened.  i am freakishly lost at this point and can not find a replacement library.
8  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 04:50:42 pm
see post above.  i cant even get the address printer to compile right now.
9  Community / Local Groups / Re: LOS ANGELES AREA? or SO CAL? on: April 01, 2012, 04:49:55 pm
interested as well but an hour drive from Oxnard is too much for me to make even if its once a week.
10  Community / Local Groups / Ventura CA anyone on: April 01, 2012, 04:47:31 pm
looking for a group to learn and do with.  dont really care if its just a group of people hitting a coffee shop or a nice shop of their own. 
11  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 04:31:21 pm
i just tried to compile the ipaddress printer sketch and it flagged a line saying
Quote
DhcpAddressPrinter.cpp: In function 'void loop()':
DhcpAddressPrinter:57: error: 'class EthernetClass' has no member named 'maintain'

Code:
void loop()

  int status = Ethernet.maintain();
  /*
    returns:
    0: nothing happened
    1: renew failed
    2: renew success
    3: rebind fail
    4: rebind success
    */
  if(status)
  {
    long now = millis();
    Serial.print(now , DEC);
    Serial.print(" a maintain event occured after (sec):");
    Serial.println((now - lastTime)/1000, DEC);
    Serial.print("Status:");
    Serial.println(status, DEC);
    Serial.println("IP address after renew/rebind:");
    print_info();
    lastTime = now;
  }
  //simulate a somewhat huge cycle time
  delay(18400);
}
12  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 04:24:22 pm
here is the code i had to dig it out of where i had it freakishly hidden from myself.

Code:
#include <SPI.h>
#include <Ethernet.h>

const char html[] =
  "<html><head>"
    "<script type=\"text/javascript\">"
    "var r;"
    "try {"
      "r = new XMLHttpRequest();"
    "} catch (e) {"
      "try {"
        "r = new ActiveXObject('Microsoft.XMLHTTP');"
      "} catch (e) {}"
    "}"
    "function set (c) {"
      "r.open('PUT', './led/' + c, false);"
      "r.send(null);"
    "}"
    "</script>"
    "<style type=\"text/css\">"
      ".b {width:112; height:112}"
      ".g {color:lightgrey}"
    "</style>"
  "</head>"
  "<body><table height=\"100%\" width=\"100%\">"
    "<tr><td align=\"center\" valign=\"middle\">"
      "<p>"
        "<input type=\"button\" class=\"b\" style=\"background-color:#ff0000\" onclick=\"set('ff0000')\"/>&nbsp;&nbsp;"
        "<input type=\"button\" class=\"b\" style=\"background-color:#00ff00\" onclick=\"set('00ff00')\"/>&nbsp;&nbsp;"
        "<input type=\"button\" class=\"b\" style=\"background-color:#0000ff\" onclick=\"set('0000ff')\"/>"
      "</p>"
      "<p>HTML served from <a href=\"\">this</a> Arduino, made accessible by <a href=\"http://www.yaler.org/\">Yaler</a>.</p>"
    "</td></tr>"
  "</table></body></html>";

const char http200[] = "HTTP/1.1 200 OK";
const char contentLength[] = "Content-Length: ";
const char connectionClose[] = "Connection: close";
const char contentTypeTextHtml[] = "Content-Type: text/html";
const char contentTypeTextPlain[] = "Content-Type: text/plain";
const byte RECEIVING = 0,
           READ_CR = 1,
           READ_CRLF = 2,
           READ_CRLFCR = 3,
           DONE = 4;
const byte YALER_RECEIVING = 0,
           YALER_UPGRADING = 1,
           YALER_TIMEOUT = 2,
           YALER_UPGRADED = 3;
const char yalerId[] = "gsiot-vw58-1khs"; // TODO: change
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xFA }; // TODO: change
byte server[] = { 46, 137, 106, 125 }; // Oberon Yaler, TODO: change
boolean isPut;
byte state;
int count;
byte ledIndex;
byte ledUriOffset;
int htmlLength;
byte yalerState;
int yalerCount;
byte rPin = 6;
byte gPin = 5;
byte bPin = 3;
byte led[] = {0,
              0,
              0};

void setColor (byte r, byte g, byte b)
{
  // SparkFun LED
  analogWrite(rPin, r);
  analogWrite(gPin, g);
  analogWrite(bPin, b);

  // Ladyada LED
  //analogWrite(rPin, 255 - r);
  //analogWrite(gPin, 255 - g);
  //analogWrite(bPin, 255 - b); 
}

byte byteFromHexChar (char ch)
{
  byte result;
  if ((ch >= '0') && (ch <= '9'))
  {
    result = ch - '0';
  }
  else if ((ch >= 'a') && (ch <= 'f'))
  {
    result = 10 + (ch - 'a');
  }
  else if ((ch >= 'A') && (ch <= 'F'))
  {
    result = 10 + (ch - 'A');
  }
  else
  {
    result = 0;
  }
  return result;
}

void parseRequestChar (char ch)
{
  // PUT /<yaler-id>/led/ff0000 ... \r\n\r\n
  // GET /<yaler-id>/led ... \r\n\r\n
  if (count == 0) {
    isPut = ch == 'P';
  }
  else if ((count >= ledUriOffset) && (count < ledUriOffset + 6))
  {
    byte d = byteFromHexChar(ch);
    //Serial.print(ch);
    if ((count - ledUriOffset) % 2 == 0)
    {
      led[ledIndex] = d;
    }
    else
    {
      led[ledIndex] = led[ledIndex] * 16 + d;
      ledIndex++;
    }
  }
  if (state == RECEIVING)
  {
    if (ch == '\r')
    {
      state = READ_CR;
    }
  }
  else if (state == READ_CR)
  {
    // assert ch == '\n'
    state = READ_CRLF;
  }
  else if (state == READ_CRLF)
  {
    if (ch == '\r') {
      state = READ_CRLFCR;
    }
    else
    {
      state = RECEIVING;
    }
  }
  else if (state == READ_CRLFCR)
  {
    // assert ch == '\n'
    state = DONE;
  }
  count++;
}

void parseYalerResponseChar (char ch)
{
  // HTTP/1.1 101 ... \r\n\r\n
  // HTTP/1.1 204 ... \r\n\r\n
  if (yalerState == YALER_RECEIVING)
  {
    if (yalerCount == 9)
    { // sizeof("HTTP/1.1 ?") - 1;
      if (ch == '1') { // 101
        yalerState = YALER_UPGRADING;
      }
      else
      { // 204
        // assert ch == '2'
        yalerState = YALER_TIMEOUT;
      }
    }
  } else if (yalerState == YALER_UPGRADING)
  {
    if (yalerCount == 75)
    { // sizeof("HTTP/1.1 101 ... \r\n\r\n") - 1
      yalerState = YALER_UPGRADED;
    }
  }
  yalerCount++;
}

void sendYalerPostRequest (EthernetClient c)
{
  c.print("POST /");
  c.print(yalerId);
  c.println(" HTTP/1.1");
  c.println("Upgrade: PTTH/1.0");
  c.println("Connection: Upgrade");
  c.println("Host: www.yaler.net");
  c.print(contentLength);
  c.println("0");
  c.println();
  c.flush();
}

void receiveYalerResponse (EthernetClient c)
{
  yalerCount = 0;
  yalerState = YALER_RECEIVING;
  while (c.connected() && (c.available() <= 0)) {} // Yaler sends 101 or 204 in < 30s
  while (c.connected() && (c.available() > 0) &&
    (yalerState != YALER_UPGRADED) &&
    (yalerState != YALER_TIMEOUT))
  {
    char ch = c.read();
    parseYalerResponseChar(ch);
  }
}

void sendPutResponse (EthernetClient c)
{
  c.println(http200);
  c.println(contentTypeTextPlain);
  c.print(contentLength);
  c.println("3");
  c.println(connectionClose);
  c.println();
  c.print("200");
  c.flush();
}

void sendGetResponse (EthernetClient c)
{
  c.println(http200);
  c.println(contentTypeTextHtml);
  c.print(contentLength);
  c.println(htmlLength);
  c.println(connectionClose);
  c.println();
  c.print(html);
  c.flush();
}

void receiveRequest (EthernetClient c)
{
 
  count = 0;
  ledIndex = 0;
  state = RECEIVING;
  while (c.connected() && (c.available() > 0) && (state != DONE))
  {
    char ch = c.read();
    //Serial.print(ch);
    parseRequestChar(ch);
  }
}

void setup()
{
  //Serial.begin(9600);
  //Serial.println("setup");
  pinMode(rPin, OUTPUT);
  pinMode(gPin, OUTPUT);
  pinMode(bPin, OUTPUT);
  setColor(255, 255, 255);
  Ethernet.begin(mac);
  htmlLength = sizeof(html) - 1;
  ledUriOffset = sizeof("PUT /") +
                 sizeof(yalerId) +
                 sizeof("/led/") - 3 * 1;
  setColor(0, 0, 0);
}

void loop()
{
  EthernetClient client;
  client.connect(server, 80);
  Ethernet.maintain();
  if (client.connected())
  {
    //Serial.println("connected");
    sendYalerPostRequest(client);
    receiveYalerResponse(client);
    if (yalerState == YALER_UPGRADED)
    {
      //Serial.println("upgraded");
      receiveRequest(client);
      if (state == DONE)
      {
        if (isPut)
        {
          setColor(led[0], led[1], led[2]);
          sendPutResponse(client);
        }
        else
        {
          sendGetResponse(client);
        }
      }
    }
    else
    {
      //Serial.println("timeout");
    }
    client.stop();
  }
}
13  Using Arduino / Networking, Protocols, and Devices / Re: ethernet shield problem on: April 01, 2012, 04:11:43 pm
i use a linksys wireless router with 4 ports for wired lines.  if you go to the router GUI and status -> local network tab you can see the client statuses.  all my computers say how long the lease is left but the arduino shows expired and i can not access it.
14  Using Arduino / Networking, Protocols, and Devices / ethernet shield problem on: April 01, 2012, 04:01:25 pm
i have gotten a project off of instructables.com to use a website to change a light color.  its a beginner project and i used the 1.0 project code.  my problem is my router give the shield an ipaddress and it expires.  the router is set to allow 1 day leases.  however as soon as i hook up the shield and look at the addresses handed out the shield is expired.

i havent changed anything and all files are posted here http://www.instructables.com/id/Arduino-Web-LED/

i just dont know the ethernet shield enough to do anything with it in regards to troubleshooting.
15  Development / Other Software Development / Re: LCD4BIT problems on Arduino 1.0 on: March 13, 2012, 08:48:02 pm
i have had the same troubles.  i went back to 0.23 and use that.  the problem being the developer of the board needs to redo the library.
Pages: [1] 2