SSC-32 C#

Hi, I’m new to both C# and RIOS. I’m doing a final year project in college that requires me to use the Wiimote to control a Lynxmotion arm. I’m just getting into it at the moment with easy programs. I’m trying to write a program; in C#; that uses two push buttons to rotate the shoulder servo. Unfortunately, I haven’t a clue how to do it.

This is my code at the moment:

public Form1()
{
InitializeComponent();

        SerialPort serialPort1 = new SerialPort();

        serialPort1.BaudRate = 115200;
        serialPort1.PortName = "COM1";
        serialPort1.Parity = Parity.None;
        serialPort1.DataBits = 8;
        serialPort1.StopBits = StopBits.One;
        
        
    }
    
    private void Form1_Load(object sender, EventArgs e)
    {
       
    }

    private void shoulderLeft_Click(object sender, EventArgs e)
    {
        // Write a string
        serialPort1.WriteLine("#0 P1500 S750");
    }

    private void shoulderRight_Click(object sender, EventArgs e)
    {
        // Write a string
        serialPort1.WriteLine("#0 P1600 S750");
    }

    private void closePort_Click(object sender, EventArgs e)
    {
        serialPort1.Close();
    }

    private void openPort_Click(object sender, EventArgs e)
    {
        // Open the port for communications
        serialPort1.Open();
    }

}

I know that I am missing something from the serial comms but I don’t know what, but I’m hoping someone here does.

Thanks for any help.

Hi!

Maybe CR at the end?

=Carriage return character, ASCII 13. (Required to initiate action)

Yeah, I got it working now. Now to just make the Wiimote move the arm…

Hi Al,

Tough task being assigned to write code for an arm! ;>)

Glad to hear the code is working!

Maybe you could tell me a little about Wiimote, and the differences between ‘C’ and C#? I thought I saw some OOP-type references in there.

Alan KM6VV

I haven’t really looked into the differences. Only that C# can be used with .Net and it lloks a lot like Java and VB, but a bit easier than both.

The Wiimote has a three axis accelerometer in it to sense movement.
It uses bluetooth for communication so its easy to mod.

C# is basically Java. No relation to C or C++ at all.
If you know Java then it will look really familiar.