I am new to Arduino, but not new to PHP.
I am trying to create a simple connection between PHP and Arduino, so far, I have seen lots of examples of how to connect to Arduino from a PHP web page, but now, what I am trying to do is, when a button is pressed on my Arduino board, a message is sent to PHP (the message will be used to take on different actions).
So far, I have been very unsuccessful at achieving this.
I’ll appreciate any help and if possible specific examples.
PS: I am able to read the port from my terminal… I just don’t know how to get PHP to read it. ScreenShot Attached.
MY PHP Code
<?php include "phpserial.php"; $serial = new phpSerial(); $serial->deviceSet("/dev/cu.usbmodem1411"); $serial->confBaudRate(9600); //Baud rate: 9600 $serial->confParity("none"); //Parity (this is the "N" in "8-N-1") $serial->confCharacterLength(8); //Character length (this is the "8" in "8-N-1") $serial->confStopBits(1); //Stop bits (this is the "1" in "8-N-1") $serial->confFlowControl("none"); $serial->deviceOpen(); var_dump($serial->readPort()); // $serial->sendMessage(chr(10)); // start transmission // $serial->sendMessage(1); // $serial->sendMessage("0\r"); //THIS IS WHAT I SEND // $serial->sendMessage(chr(13)); // end transmission $serial->deviceClose();
In my Arduino Code, I am using
Serial.println("ready!"); to print to the serial port