In his latest post Thomas Weinert talks about using an Ardiuno board from inside of PHP (most people seem to use Python instead).
This is the version mostly described on the net. For example on Instructables. Basically you write an Arduino Scetch that listens and send plain text data on the serial port. A PHP Script triggered by a webserver request opens the port communicates with the Arduino board an outputs some HTML. The major downside of this approach is that many Arduino boards reset if the serial port is opened. So the startup and configuration has to be done any time the PHP scripts reads some data or triggers an action.
He talks about the Firmata software and an alternative to trying to call it through PHP - using one of a few non-blocking I/O libraries like React PHP. He's created his own non-blocking library that's made to work more specifically with the Firmata protocol, though. Some code samples are provided showing how to use it to make a light blink ("Hello world" for Arduino) and working with the data from a dimmer.
Link: http://www.a-basketful-of-papayas.net/2013/06/basics-of-using-arduino-from-php.html
没有评论:
发表评论