grove.grove_optical_rotary_encoder

This is the code for

Examples

from grove.grove_button import GroveButton
import time, sys

# connect to pin 5 (slot D5)
PIN = 5
encoder = GroveOpticalRotaryEncoder(PIN)

# Read the value every second and detect motion
while True:
    print("
Position: {0} “.format(encoder.position()), file=sys.stderr, end=’’)

time.sleep(0.001)

Classes

class grove.grove_optical_rotary_encoder.GroveOpticalRotaryEncoder(pin1, pin2=None)[source]

Grove optical Rotary Encoder(TCUT1600X01) class

Parameters:

pin (int) – the number of gpio/slot your grove device connected.

Inheritance

digraph inheritanced4a2880fe5 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "GroveOpticalRotaryEncoder" [URL="#grove.grove_optical_rotary_encoder.GroveOpticalRotaryEncoder",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Grove optical Rotary Encoder(TCUT1600X01) class"]; }
position(pos=None)[source]

set or get the position counter

Parameters:

pos (int) –

optinal, the position counter to be set.

if not specified, only get the current counter

Returns:

current position counter

Return type:

(int)