-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Bendeguz-Cs edited this page Mar 1, 2025
·
16 revisions
Encoder encoder()
Encoder.begin()
Encoder.read()
Encoder.limitedRead()
Encoder.setPosition()
Sets up the pins. If the value goes up for the wrong direction of rotation then flip the pins:
//value goes up for right turn
Encoder encoder(4, 5);//value goes up for left turn
Encoder encoder(5, 4);CLK_pin - CLK pin of the encoder
DT_pin - DT pin of the encoder
//Set the pins of the encoder
Encoder encoder(4, 5);Initializes the library.
none
//initialize the library
encoder.begin();Returns an integer that can be changed by the rotary encoder.
none
//Returns the value
encoder.read();Returns an integer that can be changed by the rotary encoder but can be given a lower and an upper limit.
int Minval - lower stop
int Maxval - upper stop
//Returns the value constrained between 0 and 10
encoder.limitedRead(0, 10);Sets the value oft the encoder to the pos parameter and returns HIGH if succesful else it returns LOW.
int pos - the position to set the encoder to
//sets the position of the encoder to zero
encoder.setPosition(0);//if succesful at setting the value to zero it will print "1"
Serial.println(encoder.setPosition(0))