Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            var connection = new MonoSerialConnection(args[0], SerialBaudRate.Bps_57600);
            var session = new ArduinoSession(connection, 250);

            session.MessageReceived += (sender, eventArgs) => HandleMessageReceived(eventArgs);

            session.OneWireReplyReceived += (sender, eventArgs) => HandleOneWireReplyReceived(eventArgs);

            Console.WriteLine("Waiting for FirmwareResponse");
            ResetEvent.WaitOne();

            Console.WriteLine("Setting digital pinmode");
            session.SetDigitalPinMode(2, PinMode.OneWire);

            Console.WriteLine("Sending 1-Wire search");
            session.SendOneWireSearch();

            Console.WriteLine("Waiting for OneWire search reply");
            ResetEvent.WaitOne();

            Console.WriteLine("Sending sensor read");
            session.SensOneWireSensorRead(sensorAddress);

            Console.ReadLine();
            connection.Close();

            Console.WriteLine("Done!");
        }