Arduino / PHP / Ubuntu

Hello

I try to use PHP with Arduino. I have read many forum and tutorials but no way …

can you help me ?

Here is the PHP code :

include("php_serial.class.php");


$serial = new phpSerial();
$serial->deviceSet("/dev/ttyAMCO");
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");

$serial->deviceOpen();

$serial->sendMessage("1\r");

$serial->deviceClose(); 

echo "<h1>ARDUINO 1.0 ///</h1>";

The Arduino code :

void setup() 
{
  Serial.begin(9600);

}

void loop() 
{

 if (Serial.available()) {

    Serial.println("OK");

 }

}

I use Ubuntu. I can upload some code to arduino and it usually works. If i just do : Serial.println(“OK”); it works to … the problem is in the serial …

Thanks !!!

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

Make your PC program correspond with one of them - the 3rd example will be most reliable.

This Python - Arduino demo may also be of interest (I don't use PHP - but I do use Linux)

It is important to ensure your PC program keeps the serial connection open until it is completely finished with the Arduino. The Arduino resets every time the PC program opens the serial port.

...R

Thanks

I have read your example but it don't works ...

I think understand all concept but no result ...

Is my deviceSet is well : /dev/ttyAMC0 ? I think so ...

I read too your python's example but i don't now this langague.

An other question : is it a good solution to try to use PHP for web application with arduino ? Probably java is a best solution ?

Thanks for our help

cellules49:
I have read your example but it don't works ...

That does not tell me enough so that I can help you. Which example? if you have incorporated my ideas into your program then you need to post your program so I can see what you did.

Is my deviceSet is well : /dev/ttyAMC0 ? I think so ...

That will need to be set to whatever is appropriate on your PC.

An other question : is it a good solution to try to use PHP for web application with arduino ? Probably java is a best solution ?

The Arduino will neither know nor care what programming language is used on the PC.

...R