Пример #1
0
    bool yellow = false;     //just have to make sure it starts the same as on the Arduino

    void Start()
    {
        arduinoConnector = GetComponent <ArduinoConnector>(); //to access properties of ArduinoConnector script
        arduinoConnector.Open();                              //open serial connection
        rend = GetComponent <Renderer>();                     //to access the renderer of the object
        rend.material.SetColor("_Color", Color.blue);         //set the color of the cube to BLUE
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        arm = GetComponent <GameObject>();

        wrist        = GameObject.FindObjectOfType(typeof(WristControl)) as WristControl;
        auriculaire  = GameObject.FindObjectOfType(typeof(AuriculaireControl)) as AuriculaireControl;
        ringFinger   = GameObject.FindObjectOfType(typeof(RingControl)) as RingControl;
        middleFinger = GameObject.FindObjectOfType(typeof(MiddleControl)) as MiddleControl;
        index        = GameObject.FindObjectOfType(typeof(IndexControl)) as IndexControl;
        thumb        = GameObject.FindObjectOfType(typeof(ThumbControl)) as ThumbControl;

        fingers = new List <Finger>();
        fingers.Add(auriculaire);
        fingers.Add(ringFinger);
        fingers.Add(middleFinger);
        fingers.Add(index);
        fingers.Add(thumb);

        tempFingerDegree = 255;

        connector = new ArduinoConnector();
        Debug.Log(connector.port);
        connector.Open();


        connector.MoveFinger(31, 90);
        StartCoroutine(ArduinoEvent());
    }
Пример #3
0
 private void OnMouseDown()
 {
     print("ball 1 collision");
     // a.WriteToArduino("PING1");
     // print(a.ReadFromArduino(1000));
     ArduinoConnector.ping1();
 }
 private void OnMouseDown()
 {
     print("ball 2 collision");
     // x.WriteToArduino("PING2");
     // print(x.ReadFromArduino(1000));
     ArduinoConnector.ping2();
 }
Пример #5
0
 public IEnumerable <string> GetPorts()
 {
     try
     {
         ArduinoConnector com = new ArduinoConnector();
         return(com.PortNames());
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Пример #6
0
        static void Main(string[] args)
        {
            ArduinoConnector com = new ArduinoConnector();

            foreach (var item in com.PortNames())
            {
                Console.WriteLine(item);
            }
            Console.WriteLine(com.PortConnect("COM1"));
            Console.WriteLine(com.WriteToPort("COM1", "la vai..."));
            Console.WriteLine(com.ReadFromPort("COM1"));
            Console.ReadKey();
        }
Пример #7
0
 public int SetCommands(string port, [FromBody] dynamic comando)
 {
     try
     {
         ArduinoConnector com = new ArduinoConnector();
         com.PortConnect(port);
         return(com.WriteToPort(data: comando.comando.ToString()));
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
Пример #8
0
    // Use this for initialization
    void Start()
    {
        arduino       = FindObjectOfType <ArduinoConnector>();
        startPosition = transform.position;

        rend = GetComponentsInChildren <Renderer>();

        //if (arduino != null)
        //{
        //    arduino.EnableHapticFeedback(false);
        //    arduino.AdjustHapticFeedback(intensity);
        //    //oldIntensity = intensity;
        //}
    }
Пример #9
0
        private void sendToSerial(string code) //tady davam serial pro arduino
        {
            Debug.Log(code);
            if (connector == null)
            {
                connector = gameObject.AddComponent <ArduinoConnector>();
            }

            string sound;

            switch (code)
            {
            case ("SVETLO25"):
                sound = "SoundAura";
                break;

            case ("SVETLO50"):
                sound = "SoundMagic";
                break;

            case ("SVETLO75"):
                sound = "SoundMagic";
                break;

            case ("SVETLO"):
                sound = "SoundUnlock";
                break;

            default:
                sound = "SoundFail";
                GameObject.Find("SoundAura").GetComponent <AudioSource>().Stop();
                break;
            }


            GameObject.Find("SoundMagic").GetComponent <AudioSource>().Stop();
            GameObject.Find("SoundFail").GetComponent <AudioSource>().Stop();


            GameObject.Find(sound).GetComponent <AudioSource>().Play();

            connector.WriteToArduino(code);
        }
Пример #10
0
        public IActionResult PerformAction([FromBody] ComponentDto component)
        {
            var comp = _repository.Component.GetComponentById(component.id);
            var cat  = _repository.Category.GetCategoryById(comp.Categoryid);

            ArduinoConnector connection = new ArduinoConnector();

            bool succes = false;

            succes = connection.Send_Data(comp, cat);

            if (succes)
            {
                comp.value = comp.value == 0?1:0;
                _repository.Component.UpdateComponent(comp);
                _repository.Save();

                return(Ok("action succesfull"));
            }

            return(StatusCode(500, "Internal server error"));
        }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     a = gameObject.AddComponent <ArduinoConnector>();
     a.Open();
 }
Пример #12
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
 }
Пример #13
0
 // Start is called before the first frame update
 void Start()
 {
     connector = GetComponent <ArduinoConnector>();
     rb        = GetComponent <Rigidbody>();
 }
Пример #14
0
 public void  Start()
 {
     arduino = ArduinoConnector.GetComponent <ArduinoConnector>();  //this is used to connect into arduino board
 }
Пример #15
0
 private void Start()
 {
     communicator = GetComponent <ArduinoConnector>();
 }
Пример #16
0
 void Start()
 {
     ac = arduinoConnector.GetComponent <ArduinoConnector>();
 }