I am having problems printing the results of a PHP page with Wifly.
I'm trying to use a potentiometer to select which PHP to reference, and then a push button to print the results from a thermal receipt printer. When I run the sketch, I can see it connects in the Serial Monitor, but seems to get stuck after it prints "connected". If the push button is pressed again, it goes through the connection process again, but still does not output anything from PHP?
Sorry, the outer "while loop" was meant to be commented out. I had originally tried it with just a while loop which made no difference, so tried the do/while loop.
The PHP script seams ok. The PHP prints the results when I have code printing it automatically from start up, but when I introduce this button it does not want to work.
Could it be something to do with where the (client.connect()); is?
Interesting point about increasing the range to 0-1024, what effect does this have? Regarding the PHP, when it runs without the use of a push button it outputs (prints from the receipt printer) fine and does have a timestamp which it prints, but with the push button it only outputs a strange Y with two dots over it?!
Just seams weird why the button makes such a difference - you would think it would be something quite straight forward to do.
I've tried a new approach which is getting me closer, but tantalisingly not their yet!
I have now tried sending a '$' at the end of my PHP script, and adjusted the arduino code to collect and print the PHP result until it gets the '$'. This works ok, but even after it get the '$' it keeps printing a strange ÿ character?!
Typically, the y with the two dots over it is what is printed when a -1 is printed as a character. This happens when a serial read is performed when there is nothing to read.
Test your code, calling each of the PHP scripts individually, ignoring the switch/potentiometer. Verify that each produces valid output.
Add a Serial.print() of the value in web, to make sure that the correct GET request is actually set up.
Interesting point about increasing the range to 0-1024, what effect does this have?
The map function deals in integers. It returns a value that is in the to range, if the input value is in the from range. With a from range of 0 to 1023, only one value in that range (1023) will result in the upper limit of the to range being returned. Since 1024 is not a possible output of the analogRead function, there is no danger of returning a value that is not in the to range.