Created
May 10, 2013 05:36
-
-
Save anchan828/5552597 to your computer and use it in GitHub Desktop.
UniduinoでServoを動かすサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using Uniduino; | |
public class Sample : MonoBehaviour | |
{ | |
private Arduino arduino; | |
private int angle; | |
void Start () | |
{ | |
arduino = Arduino.global; | |
arduino.Setup (() => arduino.pinMode (9, PinMode.SERVO)); | |
StartCoroutine (BlinkLoop ()); | |
} | |
IEnumerator BlinkLoop () | |
{ | |
while (true) { | |
arduino.analogWrite (9, angle); | |
yield return new WaitForEndOfFrame(); | |
} | |
} | |
void OnGUI () | |
{ | |
GUILayout.Label (string.Format ("Angle {0}", angle)); | |
angle = (int)GUILayout.HorizontalSlider (angle, 0, 179, GUILayout.Width (300)); | |
} | |
} |
Author
anchan828
commented
May 10, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment