This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Joy2arcadeliftflagtouch.c
76 lines (69 loc) · 2.48 KB
/
Joy2arcadeliftflagtouch.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma config(Hubs, S1, HTMotor, none, none, none)
#pragma config(Hubs, S2, HTMotor, none, none, none)
#pragma config(Sensor, S3, touchSensor, sensorTouch)
#pragma config(Motor, motorA, vacuumA, tmotorNXT, openLoop, encoder)
#pragma config(Motor, motorB, vacuumB, tmotorNXT, openLoop, encoder)
#pragma config(Motor, motorC, , tmotorNXT, openLoop)
#pragma config(Motor, mtr_S1_C1_1, leftMotor, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, rightMotor, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S2_C1_1, flag, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S2_C1_2, lift, tmotorTetrix, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
//Arcade Joystick;
void ArcadeControl(int move, int turn) //Setup Left Joystick on Contoller 2 for forward/backward movement. Right Joystick for left/right
{
int left = move - turn;
int right = move + turn;
motor[leftMotor] = left;
motor[rightMotor] = right;
}
//
// Main task - program entry point
//
task main()
{
while (true)
{
getJoystickSettings(joystick);
ArcadeControl(joystick.joy2_y1, joystick.joy2_x2); //y1 is forward/backward. x2 is left/right.
// Block Intake
if (joy1Btn(2) == 1) // if Button (2)"A" is pressed on Joystick1:
{
motor[vacuumA] = 100; // Turn vacuumA on at full power
motor[vacuumB] = 100; // Turn vacuumB on at full power
}
else if (joy1Btn(3) == 1) // if Button (3)"B" is pressed on Joystick1:
{
motor[vacuumA] = -100;
motor[vacuumB] = -100;
}
else
{
motor[vacuumA] = 0; // Turn both motors Off
motor[vacuumB] = 0;
}
// Scissor Lift
if (joy1Btn(4) == 1) //if Button "Y" is pressed on Joystick 1 motor will lift scissors at 60% power
{
motor[lift] = 60;
}
else if ((joy1Btn(1) == 1) & (SensorValue(touchSensor) == 0)) //if Button "X" is pressed on Joystick 1 motor will lower scissors at 60% power
{
motor[lift] = -60; // Run lift downwards //
}
else
{
motor[lift] = 0; // Turn Lift Motor Off
}
//Flag
if (joy2Btn(2) == 1) // When you press "A" on Joystick 2 it activates the flag turn
{
motor[flag] = 100; // Flag motor spins clockwise to raise flag up
}
else
{
motor[flag] = 0; // Turn flag motor Off
}
}
}