Go Down

Topic: why not work loop ? (Read 1 time) previous topic - next topic


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

char buffer[1000];
int sensorPin = A0; // select the input pin for the potentiometer
int sensorPin2 = A1;
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
int sensorValue2 = 0;

// 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 };

byte ip[] = { 192,168,1,177 };
byte server[] = { 192,168,1,185 }; // Google

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):

Client client(server, 80);

void setup() {
    pinMode(ledPin, OUTPUT);
  Ethernet.begin(mac, ip);
  digitalWrite(ledPin, HIGH);
  digitalWrite(ledPin, LOW);
   // if you get a connection, report back via serial:
  if (client.connect()) {

  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");

void loop() {
  sensorValue  =  analogRead(sensorPin);
        sensorValue2 = analogRead(sensorPin2);
    sprintf(buffer, "GET /arduino/connet.php?val1=%d&val2=%d HTTP/1.0",sensorValue ,sensorValue2);
        client.println(); }

this code insert only one line through GET. i dont undrestand why insert only one and not work loop :(



Most likely the connection closes...
This... is a hobby.


Code: [Select]

char buffer[1000];

this code insert only one line through GET. i dont undrestand why insert only one and not work loop :(

1000 chars = 1000 Bytes. Arduino has only 2KiB of RAM memory (2048 Bytes), so you are allocating half of the memory it has. Change it to 70 and you'll save a lot of RAM.
I don't know what is the problem in your caso, but perhaps you are using all the RAM and Arduino is freezing.
You can also try:
Code: [Select]

    sprintf(buffer, "GET /arduino/connet.php?val1=%d&val2=%d HTTP/1.0\r\n\r\n", sensorValue, sensorValue2);

Blog pt_BR: http://blog.justen.eng.br/
Curso de Arduino (Arduino Course, in Brazil) - http://www.CursoDeArduino.com.br/

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131