Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Robotc 4-wheel Omniwheel Joystick Test
SUBMITTED BY:
Guest
DATE:
Dec. 24, 2013, 11:33 p.m.
FORMAT:
Text only
SIZE:
2.8 kB
Raw
Download
Tweet
HITS:
1125
Go to comments
Report
#include "JoystickDriver.c"
task main()
{
while(true)
{
getJoystickSettings(joystick);
if(joystick.joy1_y1>10)//if the joystick is pressed backward
{
if(joystick.joy1_x1<-80)
{
//go 315 degrees
motor(motorD) = 60;
motor(motorE) = 0;
motor(motorF) = 0;
motor(motorG) = -60;
}
else
{
if(joystick.joy1_x1>80)
{
//go 45 degrees
motor(motorD) = -60;
motor(motorE) = 0;
motor(motorF) = 0;
motor(motorG) = 60;
}
else
{
//go backward
motor(motorD) = -60;
motor(motorE) = 60;
motor(motorF) = -60;
motor(motorG) = 60;
}
}
}
else
{
if(joystick.joy1_y1<-10)
//if joystick is pressed forwards
{
if(joystick.joy1_x1<-80)
{
//go 225 degrees
motor(motorD) = 0;
motor(motorE) = 60;
motor(motorF) = -60;
motor(motorG) = 0;
}
else
{
if(joystick.joy1_x1>80)
{
//go 135 degrees
motor(motorD) = 0;
motor(motorE) = -60;
motor(motorF) = 60;
motor(motorG) = 0;
}
else
{
//go forwards
motor(motorD) = 60;
motor(motorE) = -60;
motor(motorF) = 60;
motor(motorG) = -60;
}
}
}
else
{
if(joystick.joy1_x1<-100)
//joystick pressed to the left
{
//go left
motor(motorD) = 60;
motor(motorE) = 60;
motor(motorF) = -60;
motor(motorG) = -60;
}
else
{
if(joystick.joy1_x1>100)
//joystick pressed to the right
{
//go right
motor(motorD) = -60;
motor(motorE) = -60;
motor(motorF) = 60;
motor(motorG) = 60;
}
else
{
//currently not working
if(joystick.joy2_x2<-100)
//if right joystick is pressed to the left
{
//rotate left
motor(motorD) = 60;
motor(motorE) = 60;
motor(motorF) = 60;
motor(motorG) = 60;
}
else
{
if(joystick.joy2_x2>100)
//if right joystick is pressed to the right
{
//rotate right
motor(motorD) = -60;
motor(motorE) = -60;
motor(motorF) = -60;
motor(motorG) = -60;
}
else
{
//stay still
motor(motorD) = 0;
motor(motorE) = 0;
motor(motorF) = 0;
motor(motorG) = 0;
}
}
}
}
}
}
}
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus