Hey guys, I'm a tad confused. I was wondering if any c# experts would help me out on this nooby question. I want to (firstly) send a single number to my arduino board, from my c# form. (Later i would like to send a whole array of numbers to my board).
I began writing this code but I'm just stuck on how to send the variable from my numeric up down box, (Number1.Value). It always returns errors about the variables being in the wrong type, which unfortunately I do not understand.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SimpleSerial
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Stop.Enabled = false;
Send.Enabled = false;
number1.ReadOnly = true;
}
private void Start_Click(object sender, EventArgs e)
{
serialPort1.PortName = "COM1";
serialPort1.BaudRate = 9600;
serialPort1.Open();
if (serialPort1.IsOpen)
{
Start.Enabled = false;
Stop.Enabled = true;
Send.Enabled = true;
number1.ReadOnly = false;
}
}
private void Stop_Click(object sender, EventArgs e)
{
if (serialPort1.IsOpen)
{
serialPort1.Close();
Start.Enabled = true;
Stop.Enabled = false;
Send.Enabled = false;
number1.ReadOnly = true;
}
}
private void Send_Click(object sender, EventArgs e)
{
// on click, send an array of numbers to arduino
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (serialPort1.IsOpen) serialPort1.Close();
}
}
}
Any help, advice or anything appreciated
Thanks