This small example start motorA via wifi.
Hope it helps using monobrick!
regards André
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 MonoBrick.EV3;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Brick<Sensor, Sensor, Sensor, Sensor> ev3;
public Form1()
{
InitializeComponent();
//OpenBrick(10);
}
private void OpenBrick(int wichone)
{
ev3 = new Brick<Sensor, Sensor, Sensor, Sensor>("wifi");
ev3.Connection.Open();
}
private void button1_Click(object sender, EventArgs e)
{
//OpenBrick(10);
var waarde = (sbyte)(trackBar1.Value);
string snelheid = "Forward";
if (waarde > 0 )
{
snelheid = "Forward";
}
else
{
snelheid = "Reverse";
}
ev3.MotorA.On(waarde);
label1.Text = snelheid + " " + waarde.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
OpenBrick(10);
//ev3.Connection.Open();
}
private void button2_Click(object sender, EventArgs e)
{
var waarde = (sbyte)(trackBar1.Value);
string snelheid = "STOP";
//OpenBrick(10);
ev3.MotorA.On(0);
label1.Text = snelheid + " " + waarde.ToString();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//OpenBrick(10);
ev3.MotorA.On(0);
ev3.Connection.Close();
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
var waarde = (sbyte)(trackBar1.Value);
label1.Text = "Speed = "+ waarde.ToString();
}
}
}
EV3 form example
Who is online
Users browsing this forum: No registered users and 7 guests