Skip to content

Instantly share code, notes, and snippets.

@anchan828
Created May 10, 2013 06:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchan828/5552743 to your computer and use it in GitHub Desktop.
Save anchan828/5552743 to your computer and use it in GitHub Desktop.
Uniduinoで明るさセンサのサンプル
using UnityEngine;
using System.Collections;
using Uniduino;
public class Sample : MonoBehaviour
{
//3.3V
private Arduino arduino;
void Start ()
{
arduino = Arduino.global;
arduino.Setup (() => {
arduino.pinMode (14, PinMode.ANALOG); // analog in A0
});
StartCoroutine (Loop ());
}
IEnumerator Loop ()
{
while (true) {
light.intensity = ((300f / arduino.analogRead (0)));
yield return new WaitForEndOfFrame();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment