Hello,
Earlier, my team wired up some encoders on our drive train for testing. I then wrote some code to bring up the number of encoder clicks. However, every time I open up Net Console, I get the output “Clicks: 0”
I’m wondering if this is a programming, or an electrical, or mechanical issue. My code is as follows. (I’m only going to include the code that relates to the encoders)
#include "WPILib.h"
class RobotDemo : public SimpleRobot
{
Encoder *rightEncoder;
public:
RobotDemo()
{
//Encoders
rightEncoder = new Encoder (3,4);
rightEncoder->Start();
}
void OperatorControl()
{
while (IsOperatorControl()){
//Encoders
printf("Clicks: %d
", rightEncoder->GetRaw());
Wait(0.05);
}
}
The “rightEncoder” is the encoder on the right side of our drivetrain. I didn’t include the drivetrain code, but when I move the right side of the robot, the printout is still “Clicks:0”
Are there any flaws with my code, or could it possibly be an electrical or a mechanical issue?
Any help is greatly appreciated.