Comunque c'era un errore nel passaggio dei parametri in php, ma ora l'ho risolto e come debug ho messo la stampa dello stato una volta inviato
ed infatti mi stampa 1 e 0..... ma il led comunque non si accende
<?php
include 'elementi/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("COM3");
// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
// Then we need to open it
$serial->deviceOpen();
echo '<form action="arduino.php" method="post">
<label><input name="led" type="radio" value="1" />Accendi</label>
<label><input name="led" type="radio" value="0" />Spegni</label>
<input type="hidden" name="nascosto" />
<input type="submit" value="invia" />
</form>';
if (isset($_POST['nascosto'])==TRUE)
{
$stato= $_POST['led'];
if (isset($stato)==TRUE)
{
$serial->sendMessage('1');
echo $stato;
}
elseif (isset($stato)==TRUE)
{
$serial->sendMessage('0');
echo $stato;
}
}
$serial->deviceClose();
?>
Scusa ma qui il led lo hai impostato sul PIN 6 e non sul 13. Hai modificato quel valore nelle prove successive?
Altra domanda stupida che al momento mi viene in mente, per caso hai montato su Arduino, l'Ethernet Shield anche se non lo stai utilizzando? Sull'Ethernet Shield i PIN 10-13 servono per la comunicazione con il controller ethernet e infatti dalla versione Ethernet Shield R3 non è stato più montato il mini LED 13 sulla scheda.
Scusami se per caso ti ho fatto una domanda banale.
Cioa,
Gianni
ho cambiato i caratteri da passare in 'o' e 'f'
ora il led si accende ma non si spegne più, e senza il condensatore lampeggia solamente, quindi serve togliere l'autoreset XD
<?php include "elementi/menu.html"; ?>
</div>
<div id="contenitore">
<div id="utente">
<?php include"elementi/login.html"; ?>
</div>
<div id="parte_centrale">
<h1>Prova funzione arduino</h1><hr />
<?php
include 'elementi/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("COM3");
// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
// Then we need to open it
$serial->deviceOpen();
echo '<form action="arduino.php" method="post">
<label><input name="led" type="radio" value="o" />Accendi</label>
<label><input name="led" type="radio" value="f" />Spegni</label>
<input type="hidden" name="nascosto" />
<input type="submit" value="invia" />
</form>';
if (isset($_POST['nascosto']))
{
$stato= $_POST['led'];
if (isset($stato)==TRUE)
{
$serial->sendMessage('o');
echo $stato;
}
elseif (isset($stato)==TRUE)
{
$serial->sendMessage('f');
echo $stato;
}
$serial->deviceClose();
}
else
echo'errore';
?>
comunque anche usando u altro pin, ho usato il pin 6
col condensatore per togliere l'auto reset, e anche sensa, il led si accende ma poi non si spegne più