Created
May 10, 2013 06:34
-
-
Save anchan828/5552743 to your computer and use it in GitHub Desktop.
Uniduinoで明るさセンサのサンプル
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 | |
{ | |
//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