|
Page 1 of 1
|
[ 4 posts ] |
|
| Author |
Message |
|
vincent6liu
Rookie
Joined: Thu Nov 29, 2012 9:04 pm Posts: 7
|
 Check my code please!
***************************************************************************************************************************************** #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop) #pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone) #pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone) #pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone) #pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone) #pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone) #pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c" // Tells ROBOTC to include the driver file for the joystick. task main() { while(true) { getJoystickSettings(joystick); // Update Buttons and Joysticks
motor[motorD] = joystick.joy1_y1; motor[motorE] = joystick.joy1_y1;
if (joystick.joy1_x1 > 0) { motor[motorD] = joystick.joy1_x1; motor[motorE] = 0; } else { motor[motorE] = joystick.joy1_x1; motor[motorD] = 0; } } } ***************************************************************************************************************************************** We're trying to control the base motors with only joystick.joy1_y1 and joystick.joy1_x1. So what's wrong with this code? Any suggestions?
|
| Fri Nov 30, 2012 8:46 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Check my code please!
Please use the code tag like this:  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop) #pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone) #pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone) #pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone) #pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone) #pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone) #pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c" // Tells ROBOTC to include the driver file for the joystick.
task main() { while(true) { getJoystickSettings(joystick); // Update Buttons and Joysticks
motor[motorD] = joystick.joy1_y1; motor[motorE] = joystick.joy1_y1;
if (joystick.joy1_x1 > 0) { motor[motorD] = joystick.joy1_x1; motor[motorE] = 0; } else { motor[motorE] = joystick.joy1_x1; motor[motorD] = 0; } } } |  |  |  |  |
It looks like you are trying to do arcade drive. If so, it should look something like this:
|
| Fri Nov 30, 2012 9:02 pm |
|
 |
|
vincent6liu
Rookie
Joined: Thu Nov 29, 2012 9:04 pm Posts: 7
|
 Re: Check my code please!
Will the robot be able to move backwards in this way?
Last edited by vincent6liu on Sun Dec 02, 2012 2:11 pm, edited 1 time in total.
|
| Fri Nov 30, 2012 10:48 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Check my code please!
Yes, it can move forward, backward, turn left and turn right. Whichever direction you want to command it.
|
| Sat Dec 01, 2012 8:25 am |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 7 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|