Html Raspberry Pi直流电机速度web服务器

Html Raspberry Pi直流电机速度web服务器,html,raspberry-pi,webserver,Html,Raspberry Pi,Webserver,我正试图通过raspberry上的web服务器控制一辆机器人汽车(带有两个直流电机)。不过我想放慢速度。。。我不知道该怎么做。 我还有一个程序可以让它自己运行(不是通过web服务器运行)(如果你知道的话,机器人车后面的那一行),我使用了: int softPwmCreate (int pin, int initialValue, int pwmRange) ; void softPwmWrite (int pin, int value) ; 从你那里得到的 这太棒了!但是,当然,这在web服

我正试图通过raspberry上的web服务器控制一辆机器人汽车(带有两个直流电机)。不过我想放慢速度。。。我不知道该怎么做。 我还有一个程序可以让它自己运行(不是通过web服务器运行)(如果你知道的话,机器人车后面的那一行),我使用了:

int softPwmCreate (int pin, int initialValue, int pwmRange) ;

void softPwmWrite (int pin, int value) ;
从你那里得到的

这太棒了!但是,当然,这在web服务器上不起作用 我真的不知道如何做到这一点,而且我对这一切都比较陌生,所以我希望你能帮助我

<html>
<head>
</head>
<body>
<form method=GET action="sumo1.php">
<input name="button" type="submit" value="&#8593;"> <!--  ↑  -->
<input name="button" type="submit" value="&#8595;"> <!--  ↓  -->
<input name="button" type="submit" value="&#8592;"> <!--  ←  -->
<input name="button" type="submit" value="&#8594;"> <!--  →  -->
<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"] == "&#8593;") //Forward
{
system("gpio write 2 1");
system("gpio write 3 0");
system("gpio write 4 1");
system("gpio write 5 0");
};

if ($_GET["button"] == "&#8595;") //Backwards
{
system("gpio write 2 0");
system("gpio write 3 1");
system("gpio write 4 0");
system("gpio write 5 1");

};

if ($_GET["button"] == "&#8592;") //Left
{
system("gpio write 2 1");
system("gpio write 3 0");
system("gpio write 4 0");
system("gpio write 5 1");

};

if ($_GET["button"] == "&#8594;") //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>


你能告诉我们你是如何通过webserver调用这个的吗?@dastaan我在我的问题中添加了代码:)我不确定我是否理解正确。您现有的代码运行良好(使用系统gpio调用),现在您想添加pwm支持,以便可以控制速度?如果是这种情况,您可以查看此链接-->和gpio库中的pwm命令。我不需要控制速度。我只是想让它总体上慢一点。以现在的速度,这是不可能控制的。可能是你可以编写一个自定义python脚本,它以开始/停止、速度和方向为参数(从一个文件中),并在启动时以默认的停止状态运行,然后你可以更改该配置文件来更改所有这些参数。不确定这是否是一个好的解决办法,但它应该起作用。就速度而言,您可以在一秒钟内拥有启动/停止时间,以创建虚拟pwm效果来控制速度。