Arduino serial communication php

Below is the code php /html code

<?php if (isset($_GET['action'])) { require("php_serial.class.php"); $serial = new phpSerial(); $serial->deviceset('COM4'); $serial->confBaudRate(115200); $serial->deviceOpen(); if ($_GET['action'] =="a") { $serial->sendMessage("0\r"); } if ($_GET['action'] =="b") { $serial->sendMessage("1\r"); } if ($_GET['action'] =="c") { $serial->sendMessage("2\r"); } else if ($_GET['action'] =="d") { $serial->sendMessage("3\r"); } $serial->deviceClose(); } ?> ARDUINO

Arduino

red on

red off

green on

green off

The arduino code is below
int redpin =13;
int greenpin =8;
int fanpin =9;
int incomingbyte;

void setup()
{
Serial.begin(115200);
pinMode(redpin,OUTPUT);
pinMode(greenpin,OUTPUT);
pinMode(fanpin,OUTPUT);
}

void loop()
{
if(Serial.available()>0)
{
incomingbyte=Serial.read();
}
if(incomingbyte == ‘0’)
{
digitalWrite(redpin,HIGH);
}
if(incomingbyte == ‘1’)
{
digitalWrite(redpin,LOW);
}
if(incomingbyte == ‘2’)
{
digitalWrite(greenpin,HIGH);
}
if(incomingbyte == ‘3’)
{
digitalWrite(greenpin,LOW);
}

}

I am using php_serial.class.php

Now the question is

When I run the php code ,only “0” is transmitted to the arduino. The arduino do not get any other integer. I have done all permutations, but could not debug.
Can anyone please help me
Please

subhendusc: When I run the php code ...

Since you're asking about a problem in PHP code, a PHP forum is the place to ask it.

Do you mean if you click on e.g. your "b" link, nothing is sent? Or after clicking "a", only "0\r" is transmitted and nothing else?

When I run the php code ,only "0" is transmitted to the arduino. The arduino do not get any other integer. I have done all permutations, but could not debug. Can anyone please help me Please

Well, there are two probable issues with having PHP write to a pc com port. The Windows version of PHP was not designed to do hardware I/O functions, and apparently writes to the com port as if it is a file (just like a batch file does). When the writing occurs, the com port is opened (causing the DTR line to blip high), the data is sent to the com port, and the com port closes. On the arduino end, the arduino by design resets when the serial DTR line blips high. This results in the arduino resetting while PHP is sending it data. The fix is to use a ~5uf capacitor between the arduino ground and reset pin, or a ~100ohm resistor between the arduino +5v and the reset pin. These will need to be removed when code is being up loaded to the arduino.