Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (bridgeRunning)
            {
                return;
            }

            if (firmataPortsSelection.SelectedIndex < 0)
            {
                MessageBox.Show("You need to select a serial port before you can start bridge");
                bridgeRunning = false;
                return;
            }

            disableControls();

            string serialPortName = firmataPortsSelection.SelectedItem.ToString();

            try
            {
                arduinoInterface = new Firmata(serialPortName, 57600, true, 1000);

                // setup test led
                arduinoInterface.pinMode(13, Firmata.OUTPUT);

                if (turnCoordinatorTurnRateEnabled.Checked)
                {
                    arduinoInterface.pinMode(Convert.ToInt32(turnRatePinNr.Value), Firmata.SERVO);
                    arduinoInterface.analogWrite(Convert.ToInt32(turnRatePinNr.Value), 90);
                }

                if (TASEnabled.Checked)
                {
                    arduinoInterface.pinMode(Convert.ToInt32(TASpinnr), Firmata.SERVO);
                    arduinoInterface.analogWrite(Convert.ToInt32(TASpinnr), 0);
                }

                if (turnCoordinatorBallPosEnabled.Checked)
                {
                    arduinoInterface.pinMode(Convert.ToInt32(turnBallPosPinNr.Value), Firmata.SERVO);
                    arduinoInterface.analogWrite(Convert.ToInt32(turnBallPosPinNr.Value), 90);
                }

                bridgeRunning = true;

                startStopLabel.Text      = "Running";
                startStopLabel.ForeColor = Color.Green;
            }
            catch (Exception Ex)
            {
                startStopLabel.Text      = "Stopped";
                startStopLabel.ForeColor = Color.Red;
                MessageBox.Show("Start Bridge Error: " + Ex.Message);
                bridgeRunning = false;
                enableControls();
            }
        }
Exemple #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     arduinoInterface = new Firmata("com85", 57600, true, 1000);
     arduinoInterface.pinMode(13, Firmata.OUTPUT);
     arduinoInterface.pinMode(9, Firmata.SERVO);
     arduinoInterface.pinMode(11, Firmata.SERVO);
     arduinoInterface.analogWrite(9, trackBar1.Value);
     arduinoInterface.analogWrite(11, trackBar1.Value);
 }
Exemple #3
0
        public Form1()
        {
            InitializeComponent();

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
            string version = fvi.FileVersion;

            toolStripStatusLabel1.Text = "FSUIPC - Firmata Bridge Version " + version;
            label26.Text = "FSUIPC - Firmata Bridge Version";

            // get list of serial ports
            string[] ports = Firmata.list();

            firmataPortsSelection.Items.Clear();

            for (int c = 0; c < ports.Length; c++)
            {
                firmataPortsSelection.Items.Add(ports[c]);
            }

            openFSUIPC();
        }