Go Down

Topic: How to build app with c# code? (Read 1 time) previous topic - next topic

Riaan Deyzel

Good day

I would like to know what to do to make an app work, and what to add if I only got the source code like in the examle on this page http://maxatcurotek.blogspot.com/2010/03/controlling-servo-attached-to-arduino.html and the source below:
Code: [Select]
C#.NET 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;

namespace WindowsFormsApplication1
public partial class Form1 : Form
public Form1()

private void trackBar1_Scroll(object sender, EventArgs e)
serialPort1.Write(trackBar1.Value + "s");

private void Form1_Load(object sender, EventArgs e)

I do have Microsoft Visual Studio installed.


That's not all of the source code, it won't work, you need the .Designer.cs file that goes with that file
Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Riaan Deyzel

Thanks, I have tried to copy and paste the code to Visual studio & then added the Serial port tool and set It to COM4 as well as added a slider, and the error I got did mention "Projects\Slider\obj\Debug\Slider.dll' doesn't contain any UserControl types" this, so does that mean that there is a way to fix this, or is the control type unique to the user that designed the app?


Your "form" only has 2 components, why don't you start from scratch to avoid the error? It might be a project settings issue.
Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Riaan Deyzel

I have tried to do this, bit I suck at c#.
I will continue to look around for some source code like the c# code above, but with 2 servo support.
Thanks anyway.


Why don't you let arduino deal with the servo controlling issue and just use C# to tell arduino what do to? I don't really know what you want to do but lets say that you are controlling the servo (s) with arduino, then you can create a C# that communicates with Arduino thru serial. As you are trying to use the track bar, you can just send to arduino the trackBarName.Value (int) and move the servo at your will with that value.
If you think you have it, you don't. If you think you don't have it, you still don't.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131