When i open my monitor and execute my php code, I get following message:
Warning: fopen(com7): failed to open stream: Permission denied in C:\xampp\htdocs\arduino\test.php on line 18
Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\arduino\test.php on line 22
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\arduino\test.php on line 24
When i open my monitor and execute my php code, I get following message:
So, why do you expect the Arduino to do anything?
echo "<p>Wrote $i </p>";
fwrite($fp,1);
I can't imagine the relationship between what the echo statement says and what the code does. Perhaps the echo statement needs to be:
echo "<p>Mary had a little lamb. It's fleece was white as snow...</p>";
In any case, opening the serial port (as the PHP script is trying to do), resets the Arduino. Closing the serial port, as the PHP script is trying to do, also resets the Arduino. Since you do not wait for the Arduino to reset before sending it data, and you reset it again after sending it data, I can't see that the Arduino is actually going to accomplish anything. Therefore, I can't see the purpose of this exercise.
In any case, opening the serial port (as the PHP script is trying to do), resets the Arduino. Closing the serial port, as the PHP script is trying to do, also resets the Arduino. Since you do not wait for the Arduino to reset before sending it data, and you reset it again after sending it data, I can't see that the Arduino is actually going to accomplish anything. Therefore, I can't see the purpose of this exercise.
Now I use a sleep. You mean it like this or?
$fp = fopen("com7", "w+") or die("can't open file");
$i = ($_GET['command'] > 0) ? $_GET['command'] : 0;
echo "<p>Wsrote $i </p>";
fwrite($fp, chr($i));
sleep(3); //Now here is a sleep.. some time for the arduino
fclose($fp);
But when I open my serial monitor and just then, there is still the error: fopen(com7): failed to open stream: Permission denied
Maybe I use the wrong port? But my IDE says "Arduino UNO on COM7"
When i open my monitor and execute my php code, I get following message:
Can I check something? You are running the PHP script on your PC? And that PC is connected to the Arduino via USB?
If you try to talk to the Arduino through the IDE serial monitor AND run another program to communicate via the Arduino serial USB, only one of them will work. They can't both have the serial port open at the same time.
If you try to talk to the Arduino through the IDE serial monitor AND run another program to communicate via the Arduino serial USB, only one of them will work. They can't both have the serial port open at the same time.
Hmm that makes sense... But what do you suggest? My plan was to control the arduino via xampp. Do u have any ideas how I can realise that?