Pages: [1]   Go Down
Author Topic: How to build app with c# code?  (Read 759 times)
0 Members and 1 Guest are viewing this topic.
Port Elizabeth, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino user South Africa
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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()
{
InitializeComponent();
}

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

private void Form1_Load(object sender, EventArgs e)
{
serialPort1.Open();
serialPort1.Write("0s");
}
}
}

I do have Microsoft Visual Studio installed.
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's not all of the source code, it won't work, you need the .Designer.cs file that goes with that file
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Port Elizabeth, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino user South Africa
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your "form" only has 2 components, why don't you start from scratch to avoid the error? It might be a project settings issue.
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Port Elizabeth, South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 48
Arduino user South Africa
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
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.
Logged

New York, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Almighty Forum, help this newbie solve his problem
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

If you think you have it, you don't. If you think you don't have it, you still don't.

Pages: [1]   Go Up
Jump to: