Hey i just figured out two important changes for ur code ....
1> change
$serial->sendMessage("0\r");
to
$serial->sendMessage('0');
and for sending '1'.
2> enable sleep.here command like this
$serial = new phpSerial(); $serial->deviceSet("COM3"); $serial->confBaudRate(9600); $serial->deviceOpen(); sleep(2);
sleep command inserts a delay. when serial port opens php in
$serial->deviceopen();
The arduino team gets an auto-grill. this way when php executes the following commands that arduino will not be able to receive them and therefore will not be able to take action. 2 is the best delay, since 1 will be very short, while others more than 2 will be long. use the php and html code in the same file as in the above message and name it "name.php" without "". it worked for me ....
source share