Using Form text box data

Discussion in 'C#' started by aabundle, Oct 4, 2010.

  1. aabundle

    aabundle New Member

    Joined:
    Oct 4, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hey Guys,

    I am pretty new to C#.

    Below is some code that i am using to send data serially to an Arduino controller. It just has some push buttons which move the wheels/motors etc of an RC car i have. I have put some text boxes onto the form and want to let any numbers put in the boxes to be sent to the controller in the same way im sending the button press information.

    Im a bit of a n00b and dont know how to do it.

    Do i nest the text box data inside a button loop or something

    any help would be appreciated. Thanks

    Michael D


    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO.Ports;
    
    namespace ArduinoController
    {
        public partial class Form1 : Form
        {
            SerialPort port;
    
            public Form1()
            {
                InitializeComponent();
                port = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One);
                port.Open();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                port.Write("i");     //Value 105 sent serially to Arduino
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                port.Write("o");     //Value 111 sent serially to Arduino
            }
    
            private void button3_Click(object sender, EventArgs e)
            {
                port.Write("p");     //Value 112 sent serially to Arduino
            }
    
            private void textBox2_TextChanged(object sender, EventArgs e)
            {
              ??????????????
            }
    
        }
    }
     
  2. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    19
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    http://www.techgeek.in
    is this related to robotics as well…seems to me like program for chassis of a robot…?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice