Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int led1 = 12;
            int led2 = 11;
            int led3 = 10;
            Arduino arduino = new Arduino("COM6");

            // initialisasi
            arduino.pinMode(led1, Arduino.OUTPUT);
            arduino.pinMode(led2, Arduino.OUTPUT);
            arduino.pinMode(led3, Arduino.OUTPUT);

            while(true)
            {
                // LED 1
                arduino.digitalWrite(led1, Arduino.HIGH);
                arduino.digitalWrite(led2, Arduino.LOW);
                arduino.digitalWrite(led3, Arduino.LOW);

                Thread.Sleep(2000); // sleep 2 detik

                // LED 2
                arduino.digitalWrite(led1, Arduino.LOW);
                arduino.digitalWrite(led2, Arduino.HIGH);
                arduino.digitalWrite(led3, Arduino.LOW);

                Thread.Sleep(2000); // sleep 2 detik


                // LED 3
                arduino.digitalWrite(led1, Arduino.LOW);
                arduino.digitalWrite(led2, Arduino.LOW);
                arduino.digitalWrite(led3, Arduino.HIGH);

                Thread.Sleep(2000); // sleep 2 detik
            }

        }
 /// <summary>
 /// Creates an instance of the Arduino object using default arguments.
 /// Assumes the arduino is connected as the HIGHEST serial port on the machine,
 /// default baud rate (115200), and a reboot delay (8 seconds).
 /// and automatically opens the specified serial connection.
 /// </summary>
 public Arduino() : this(Arduino.list().ElementAt(list().Length - 1), 115200, true, 8000)
 {
 }