当前位置: 首页>>代码示例>>Python>>正文


Python PyMata.encoder_config方法代码示例

本文整理汇总了Python中PyMata.pymata.PyMata.encoder_config方法的典型用法代码示例。如果您正苦于以下问题:Python PyMata.encoder_config方法的具体用法?Python PyMata.encoder_config怎么用?Python PyMata.encoder_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyMata.pymata.PyMata的用法示例。


在下文中一共展示了PyMata.encoder_config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PyMata

# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import encoder_config [as 别名]
import sys
import signal

from PyMata.pymata import PyMata

ENCODER_A = 2
ENCODER_B = 4
prev_value = 0

# create a PyMata instance
board = PyMata("/dev/ttyACM0")


def signal_handler(sig, frame):
    print('You pressed Ctrl+C!!!!')
    if board is not None:
        board.reset()
    sys.exit(0)

signal.signal(signal.SIGINT, signal_handler)

# configure the pins for the encoder
board.encoder_config(ENCODER_B, ENCODER_A)

while 1:
    value = board.digital_read(ENCODER_B)
    if value != prev_value:
        prev_value = value
        print(board.digital_read(ENCODER_B))
    pass
开发者ID:solishi,项目名称:woodbot,代码行数:32,代码来源:polled_encoder.py

示例2: PyMata

# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import encoder_config [as 别名]
This example illustrates using callbacks for digital and analog input.

Monitor the current analog input and digital input of two pins.
"""

import signal
import sys
import time


from PyMata.pymata import PyMata


# Instantiate PyMata
board = PyMata("/dev/ttyACM0", verbose=True)

board.encoder_config(7,2)

# Set up pin modes for both pins with callbacks for each
board.set_pin_mode(5, board.PWM, board.DIGITAL)
board.set_pin_mode(6, board.PWM, board.DIGITAL)

board.analog_write(5, 255)
board.analog_write(6, 0)

time.sleep(2)
count = board.digital_read(2)
print count
time.sleep(2)
board.analog_write(5, 0)
开发者ID:solishi,项目名称:woodbot,代码行数:32,代码来源:test_motor_drive_woodbot.py

示例3: encoder_callback

# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import encoder_config [as 别名]
ENCODER_A = 14
ENCODER_B = 15

# Indices into callback return data list
DEVICE = 0
PIN = 1
DATA = 2


def encoder_callback(data):
    print("Data = %d" % data[DATA])

# create a PyMata instance
board = PyMata("/dev/ttyACM0")


def signal_handler(sig, frame):
    print('You pressed Ctrl+C!!!!')
    if board is not None:
        board.reset()
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)

# configure the pins for the encoder
board.encoder_config(ENCODER_B, ENCODER_A, encoder_callback)

while 1:
    time.sleep(.2)
开发者ID:apptronics,项目名称:PyMata,代码行数:32,代码来源:callback_encoder.py


注:本文中的PyMata.pymata.PyMata.encoder_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。