Beste,
Ik ben een programma aam het schrijven om met een joystick een pantilt camera te besturen.
dit doe ik door middel van relais die de snelheid bepalen van de bewegingen.
De joystick bewegingen werken, en ik kan ook 1 relais open en dicht sturen.
graag had ik zo enkele relais verspreid over de hele joystick beweging zodat hij
sneller beweegd naargelang ik verder ga met de joystick.
momenteel springt de eerste relais op/af als ik nog maar net links/rechts ga.
ik zou dus graag de hele bezeging gebruiken.
weet iemand hoe dit werkt?
dit heb ik nu:
alvast heel erg bedankt
Ik ben een programma aam het schrijven om met een joystick een pantilt camera te besturen.
dit doe ik door middel van relais die de snelheid bepalen van de bewegingen.
De joystick bewegingen werken, en ik kan ook 1 relais open en dicht sturen.
graag had ik zo enkele relais verspreid over de hele joystick beweging zodat hij
sneller beweegd naargelang ik verder ga met de joystick.
momenteel springt de eerste relais op/af als ik nog maar net links/rechts ga.
ik zou dus graag de hele bezeging gebruiken.
weet iemand hoe dit werkt?
dit heb ik nu:
Code:
private void poll()
{
System.Threading.Thread.Sleep(10); //delay for 10ms
joystickDevice.Poll(); //poll the joystick
buttons = new byte[11]; //create a byte array of 0 to 11 (12 buttons) you have to change this to how many buttons your joystick has look at the website in the top comments
//under What is the joystick capable of? run that code to find out
buttons = joystickDevice.CurrentJoystickState.GetButtons();
int X = joystickDevice.CurrentJoystickState.X;
int Y = joystickDevice.CurrentJoystickState.Y;
int Z = joystickDevice.CurrentJoystickState.Z;
int output = (Y - 0) * (180 - 0) / (65535 - 0) + 0; //scale the joystick values from 0 to 65535 to 0 to 180 for the servo.
String send = Convert.ToString(output);
int numLen = send.Length;
send = numLen + send; //combine the 2 strings
//serialPort1.Write(send); //*****remove this line as well if you don't want serial communication
buttonCheck(); //calls button check to update the check boxes on the form
//updates all of the progress bars on the screen
if (X >= 33767)
{
prgX2.Value = X; //visuele indicator
serialPort12.Write("16+//"); //relais16 schakeld in
}
else
{
if (X <= 31767)
{
X = 31767 - X;
prgX1.Value = X; //visuele indicator
serialPort12.Write("16-//"); //relais 16 schakeld uit
}
}
if (Y >= 33767)
{
prgY2.Value = Y;
}
else
{
if (Y <= 31767)
{
Y = 31767 - Y;
prgY1.Value = Y;
}
}
Z = 65535 - Z;
prgZ.Value = Z;
}
Laatst bewerkt door een moderator: