Go Down

Topic: Traffic Management System using arduino uno+ethernet shield and wamp server (Read 1 time) previous topic - next topic

wildbill

c isn't a global variable - it's declared in the connection function. Globals are declared outside functions, e.g. your looptime variable.

What I'm suggesting is that you declare a global integer variable, let's call it state. Then, in your loop routine, you can do this:
Code: [Select]

void loop()
{
connection();
if(state==1)
  reset();
else if (state==2)
  redall();
}


In the connection routine, where you check the parameter you got in the http request, rather than calling your routines to set lights, just assign the approriate value to the state variable. Then when connection completes, you'll be back to loop which will choose the appropriate light function repeatedly. Subsequent http requests will now get read and can change state so that loop will pick a different function to run the lights.

Note that a switch statement would probably be more appropriate and the 1 and 2 above should really be declared as const ints or an enum but that should get you started.

 

RNSJR

i have tried it sir,

i made
Code: [Select]
char connection()
its the same execution as from my previous code.
it still cannot interfere or interrupt the function reset() while it is executing.

RNSJR

Good day sirs! now i can interrupt my traffic lights. And so i have to proceed to the next step.. which is checking the status of the traffic lights.

somewhat like reading the pin state and post it on php web. i have this code but its not working..
Code: [Select]

void fetching()
{
   int i,j,m=0;
  EthernetClient client=server.available();
  if (client) {
    Serial.println("new client");
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
       
        client.println("GET /php_site/ledStatus.php?");
       
        for(i=0;i<4;i++)
        {
            for(j=0;j<3;j++)
            {
                client.print("L");
                Serial.print("L");
                client.print(m);
                Serial.print(m);
                client.print("=");
                Serial.print("=");
                client.print(digitalRead(led[i][j]));
                Serial.print(digitalRead(led[i][j]));
                Serial.println();
                m++;
            }
        }
         client.println(" HTTP/1.1");
         Serial.println(" HTTP/1.1");
         client.println("Host: www.jfkreuter.com");
         Serial.println("Host: www.jfkreuter.com");
         client.println("User-Agent: Arduino");
         Serial.println("User-Agent: Arduino");
         client.println("Accept: text/html");
         Serial.println("Accept: text/html");
         client.println("Connection: close");
         Serial.println("Connection: close");
         client.println();
         Serial.println();
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}


i hope someone can help me with this problem. :)


PeterH

I only provide help via the forum - please do not contact me for private consultancy.

PaulS

Quote
i have this code but its not working..

It works, as in it does something. What it does is a mystery, as is what you want it to do, and how those two differ. If you provide more details, we'll provide more help.

Go Up