How to programme an encoder, help needed


#1

Okay so basically I’m a little bit of a so called ‘noob’ when it comes to programming. I sound really dumb but how do I programme an encoder, the intent for said encoder is to count how many clicks a gear will take to shoot a ball when building up tension as the idea is to ‘slip’ and have another object shoot out to hit the ball but I have no idea how to programme this said encoder. Any advice?


#2

for robotC, you can use


SensorValue(SensorName)

to get a value from the sensor.


#3

The encoder counts in degrees, so you might need to figure out how many degrees it turns. Try untilEncoderCounts(degree amount, encoder name)
and put your code above it and then stop motor after the untilEncoderCounts. Try something like this -

startMotor(shooter, 65);
untilEncoderCounts(1280, encoder);
stopMotor(shooter);

Just substitute numbers and names in to that code, it should work.


#4

@Kenzie Are you guys using V5?


#5

it shouldn’t really matter, aside from that they could use the built in motor encoder instead