网络中的Arduino和飞利浦色调可变亮度

时间:2015-06-29 13:37:46

标签: url networking arduino arduino-uno philips-hue

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

灯光状态代码:

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/

0 个答案:

没有答案