Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System.IO.Ports;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. using UnityEngine;
  5.  
  6. public class ArduinoReader : MonoBehaviour
  7. {
  8.     public ElevatorSystem _elSys;
  9.     private SerialPort sPort;
  10.  
  11.     void Start()
  12.     {
  13.         sPort = new SerialPort("COM8");
  14.         sPort.Open();          
  15.     }
  16.  
  17.     public void FixedUpdate()
  18.     {
  19.         if (sPort.BytesToRead > 0)
  20.         {
  21.             string msg = sPort.ReadLine();
  22.             _elSys.FindNewCard(msg);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement