Skip to content

Instantly share code, notes, and snippets.

@abeldantas
Created November 21, 2016 16:23
Show Gist options
  • Save abeldantas/0d3ec6b8dc911a64c96625296c1fea91 to your computer and use it in GitHub Desktop.
Save abeldantas/0d3ec6b8dc911a64c96625296c1fea91 to your computer and use it in GitHub Desktop.
Unity Toggle Pin ESP8266 NodeMCU
using System.Collections;
using UnityEngine;
public class TogglePin : MonoBehaviour
{
private int index;
private string[] commands = new[] { "pin=ON1", "pin=OFF1" };
public void Click()
{
string url = "http://192.168.4.1?" + commands[index];
WWW www = new WWW( url );
StartCoroutine( WaitForRequest( www ) );
index = index == 0 ? 1 : 0;
}
IEnumerator WaitForRequest( WWW www )
{
yield return www;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment