Quote:
Originally Posted by Joe Ross
What does the 5v light on the digital sidecar do when the additional encoders are added? Can you post your code?
In 2009, we used 5 encoders. We've used 2 encoders each year since then.
|
This is my simple encoder code to test the encoders. Also the encoder wires work, I switch the wires connected to the ports.
#include "WPILib.h"
class RobotDemo : public SimpleRobot
{
Encoder *Encoder1, *Encoder2;
CANJaguar *Jag1, *Jag2;
Servo *Shift;
DriverStationLCD *DsLCD;
Joystick *One;
public:
RobotDemo(void)
{
Encoder1 = new Encoder(2,3);
Encoder2 = new Encoder(4,5);
Jag1 = new CANJaguar(3);
Jag2 = new CANJaguar(4);
Shift = new Servo(1);
DsLCD = DriverStationLCD::GetInstance();
One = new Joystick(1);
}
void Autonomous(void)
{
}
void OperatorControl(void)
{
while (IsOperatorControl())
{
Encoder1->Start();
Encoder2->Start();
while(IsEnabled())
{
Jag1->Set(One->GetY());
Jag1->Set(One->GetY());
Shift->Set((One->GetRawAxis(4)/2)+.5);
DsLCD->Printf(DriverStationLCD::kUser_Line1,1,"Speed:%f" ,Encoder1->GetRate());
DsLCD->Printf(DriverStationLCD::kUser_Line2,2,"Speed:%f" ,Encoder2->Get());
DsLCD->UpdateLCD();
}
}
}
void Test() {
}
};
START_ROBOT_CLASS(RobotDemo);