My PHP files run motors, Forward.php makes them go one direction and Backward.php in the opposite. For some reason when I open the page and I for example press the up button it works fine, the motors run forward. Then it all goes wrong. If I press forward again nothing happens for about 10 seconds then suddenly the motors go all weird and start jittering.
If I open the index.html and press forward, then I refresh the page and press forward again that works fine...but if I refresh the page and then press the down button the motors go all weird again and do not work properly.
However if I run the motor codes from the terminal they work fine in any order no matter how many times I run them. I know the motor codes are fine and I do not think this is an issue with the pi but the website...If i run the motors from the terminal AFTER the website messes it all up then even in the terminal they stop running properly..
The php file uses system: (" python /var/www/html/Forward.py) and this has been tested on its own in the terminal and it works fine.
any help would be greatly appreciated
here is my code:
<html>
<head>
<title>RC car Control Website</title>
<link href="Website.css" rel="stylesheet">
</head>
<body>
<header>Website Controlled RC Car</header>
<button type="button" id="up"> <img src="images/up" width="50" height="50"> </button><br>
<button type="button" id="down"> <img src="images/down" width="50" height="50"/></button><br>
<button type="button" id="right"> <img src="images/right" width="50" height="50"/></button><br>
<button type="button" id="left"> <img src="images/left" width="50" height="50"/></button><br>
<script type ="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type ="text/javascript">
$(document).ready(function () {
var xhr;
$("#up").mousedown(function() {
$.ajax ({
method: "GET",
url: "http://192.168.1.94/Forward.php",
});
});
$("#up").mouseup(function() {
$.ajax ({
method: "GET",
url: "http://192.168.1.94/MotorStop.php",});
});
});
</script>
<script type ="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type ="text/javascript">
$(document).ready(function () {
var xhr;
$("#down").mousedown(function() {
$.ajax ({
method: "GET",
url: "http://192.168.1.94/Backward.php",
});
});
$("#up").mouseup(function() {
$.ajax ({
method: "GET",
url: "http://192.168.1.94/MotorStop.php",});
});
});
</script>
</body>
</html>