我正试图通过树莓上的网络服务器控制机器人车(带两个直流电机)。我想减慢它...但我不知道如何做到这一点。 我也有一个程序让它自己运行(不是通过网络服务器)(机器人汽车之后的线路,如果你知道的话),我用过:
int softPwmCreate (int pin, int initialValue, int pwmRange) ;
void softPwmWrite (int pin, int value) ;
来自here
这很棒!但是,当然,这在Web服务器上不起作用 我真的不知道该怎么做,而且我对这一切都比较新,所以我希望你能帮帮我
<html>
<head>
</head>
<body>
<form method=GET action="sumo1.php">
<input name="button" type="submit" value="↑"> <!-- ↑ -->
<input name="button" type="submit" value="↓"> <!-- ↓ -->
<input name="button" type="submit" value="←"> <!-- ← -->
<input name="button" type="submit" value="→"> <!-- → -->
<input name="button" type="submit" value="STOP">
</form>
<?php
system("gpio mode 0 output");
system("gpio mode 1 output");
system("gpio mode 6 output");
system("gpio mode 2 output");
system("gpio mode 3 output");
system("gpio mode 4 output");
system("gpio mode 5 output");
system("gpio mode 4 output");
system("gpio mode 5 output");
system("gpio write 0 1");
system("gpio write 1 1");
system("gpio write 6 1");
if ($_GET["button"] == "↑") //Forward
{
system("gpio write 2 1");
system("gpio write 3 0");
system("gpio write 4 1");
system("gpio write 5 0");
};
if ($_GET["button"] == "↓") //Backwards
{
system("gpio write 2 0");
system("gpio write 3 1");
system("gpio write 4 0");
system("gpio write 5 1");
};
if ($_GET["button"] == "←") //Left
{
system("gpio write 2 1");
system("gpio write 3 0");
system("gpio write 4 0");
system("gpio write 5 1");
};
if ($_GET["button"] == "→") //Right
{
system("gpio write 2 0");
system("gpio write 3 1");
system("gpio write 4 1");
system("gpio write 5 0");
};
if ($_GET["button"] == "STOP") //Stop
{
system("gpio write 2 0");
system("gpio write 3 0");
system("gpio write 4 0");
system("gpio write 5 0");
};
?>
</body>
<html>