sjhs_unitySerial

using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO.Ports; //시리얼 포트를 사용하기 위한 네임스페이스를 설정해준다. public class ArduinoSerial : MonoBehaviour { //시리얼포트 생성. SerialPort(“포트번호”, 통신속도); 통신 속도는 보통 9600을 사용함. //SerialPort sp = new SerialPort(“/dev/tty.usbserial-A602AKQ5”, 9600); SerialPort sp =newSerialPort(“COM3”,9600); //Windows void Start () { sp.Open(); //시리얼 포트 오픈 } void Update () { //시리얼 포트가 열려있으면 … [Read more…]

sjhs_arduino

void setup() { Serial.begin(9600); //시리얼통신을 시작한다 } void loop(){ int analogInput = analogRead(A0); //A0핀의 값을 읽어서 int형 변수에 저장 // Serial.println(analogInput); //시리얼로 analogInput 값을 보낸다 //시리얼에 A,1234 의 형태로 가변저항의 값을 전송한다 Serial.print(“A,”); Serial.println(analogInput); delay(50); //너무 빠르면 유니티에서 바로 못 읽고 쌓인다 }

2017.09.21

#include “ofApp.h” //————————————————————– void ofApp::setup(){ cout << “setup” << endl; } //————————————————————– void ofApp::update(){ //cout << “update” << endl; } //————————————————————– void ofApp::draw(){ ofSetColor(255, 255, 0); ofDrawCircle(mouseX, mouseY, 50);   ofDrawCircle(20, 500, 50); //cout << “draw” << endl;   /*     asdfasdf asdfasdf asdfasdf asdfasdf asdfasdfasdf sadfasdfasdfasdf asdfasdf   */ } //————————————————————– void ofApp::keyPressed(int … [Read more…]