Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (read)
        {
            if (var > 0)
            {
                sphere.transform.localScale = new Vector3((float)(var / 255.0f), (float)(var / 255.0f), (float)(var / 255.0f));
            }
            arduinoConnector.WriteByteToArduinoAsync(counter); //send 255 to Arduino
            counter++;
            if (counter > 255)
            {
                counter = 0;
            }

            read = false;

            arduinoConnector.ReadByteFromArduinoAsync(arduinoRead); //read from Arduino
        }
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     arduinoConnector = GetComponent <ArduinoConnector>();   //to access properties of ArduinoConnector script
     arduinoConnector.Open();                                //open serial connection
     arduinoConnector.ReadByteFromArduinoAsync(arduinoRead); //read from Arduino
 }