0

我正在从网站更改代码。我删除了 PIR 传感器变量并添加了一个距离传感器,这样我就可以用手改变亮度。我明白了,但我不知道如何在命令中更改变量“亮度”的亮度。一切都是本地的,脚本在没有可变亮度的情况下工作。

灯的状态代码:

command = "{\"hue\":50100,\"sat\":255,\"bri\":255,\"transitiontime\":"+String(random(15,25))+"}"; 
    setHue(2,command);

SetHue 方法:

boolean setHue(int lightNum,String command)
{
  if (client.connect(hueHubIP, hueHubPort))
  {
    while (client.connected())
    {
      client.print("PUT /api/");
      client.print(hueUsername);
      client.print("/lights/");
      client.print(lightNum);  // hueLight zero based, add 1
      client.println("/state HTTP/1.1");
      client.println("keep-alive");
      client.print("Host: ");
      client.println(hueHubIP);
      client.print("Content-Length: ");
      client.println(command.length());
      client.println("Content-Type: text/plain;charset=UTF-8");
      client.println();  // blank line before body
      client.println(command);  // Hue command
    }
    client.stop();
    return true;  // command executed
  }
  else
    return false;  // command failed
}

来源: http: //www.makeuseof.com/tag/control-philips-hue-lights-arduino-and-motion-sensor/

4

0 回答 0