ciao a tutti, sono alle prime armi stò cercando di far accendere un led con arduino uno tramite php...ho qualche problemino..
ho installato il server web...e messo dentro a var/www/html questi due file...presi da qui..http://paolosarteschi.altervista.org/wp/?p=375
php_serial.class.php
<?php
include "php_serial.class.php";
// Let's start the class
$serial = new phpSerial;
// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("COM1");
// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(2400);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
// Then we need to open it
$serial->deviceOpen();
// To write into
$serial->sendMessage("Hello !");
// Or to read from
$read = $serial->readPort();
// If you want to change the configuration, the device must be closed
$serial->deviceClose();
// We can change the baud rate
$serial->confBaudRate(2400);
// etc...
//
?>
-+-+-+-+-+-+++++++++++-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
define("PORT","/dev/ttyACM0");
if (isset($_GET['action'])) {
include "php_serial.class.php";
$serial = new phpSerial;
$serial->deviceSet(PORT);
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
$serial->deviceOpen();
if ($_GET['action'] == "on") {
$serial->sendMessage("a");
} else if ($_GET['action'] == "off") {
$serial->sendMessage("s");
}
$read = $serial->readPort();
print $read;
$serial->deviceClose();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test Arduino</title>
</head>
<body>
<h1>Test Arduino</h1>
<a href="<?=$_SERVER['PHP_SELF'] . "?action=on" ?>">
<button style="width:100px""><h1>ON</h1></button></a>
<a href="<?=$_SERVER['PHP_SELF'] . "?action=off" ?>">
<button style="width:100px""><h1>OFF</h1></button></a>
</body>
</html>
il problema è che non si accende il led ma solo le luci standard di arduino uno quando faccio on oppure off..