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


Python PyMata.refresh_report_firmware方法代码示例

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


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

示例1: PyMata

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

# import the API class
import time

from PyMata.pymata import PyMata

# some constants
POTENTIOMETER = 2  # this A2, an analog input
BUTTON_SWITCH = 12 # a digital input to read a push button switch

# Instantiate PyMata - in this case using the default '/dev/ttyACM0' value.
firmata = PyMata()

# Refresh, Retrieve and print Arduino Firmware version information
firmata.refresh_report_firmware()
print firmata.get_firmata_version()

# Print PyMata's version number
print firmata.get_pymata_version()

# Setup pin A2 for input
firmata.set_pin_mode(POTENTIOMETER, firmata.INPUT, firmata.ANALOG)

# Setup pin pin 12 for the switch
firmata.set_pin_mode(BUTTON_SWITCH, firmata.INPUT, firmata.DIGITAL)

# Arm pin A2 for latching a value >= 678
firmata.set_analog_latch(POTENTIOMETER, firmata.ANALOG_LATCH_GTE, 678)

# Arm pin 12 for latching when the pin goes high
开发者ID:Haobot,项目名称:PyMata,代码行数:32,代码来源:pymata_software_data_latch.py

示例2: servo_callback

# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import refresh_report_firmware [as 别名]
def servo_callback(data):
    if DEBUG:
        print("SUB:DATA:"+str(data.data))
    '''write to servo port'''
    pos=int(data.data)
    ''' fake map adc values 0-1024 to 0-180 for servo '''
    pos=int(pos/6)
    if DEBUG:
        print("Set servo to: "+str(pos))
    board.analog_write(SERVO_PIN, pos)

if __name__ == '__main__':
    try:
        ''' init ros node '''
        pub_adc = rospy.Publisher("pymata/adc", String, queue_size=10)
        rospy.init_node("pymata")
        rospy.Subscriber("pymata/adc", String, servo_callback)
        ''' init pymata and ports '''
        board = PyMata(USB_PORT)
        if DEBUG:
            board.refresh_report_firmware()
            print(board.get_firmata_firmware_version())
        board.servo_config(SERVO_PIN)
        board.set_pin_mode(ADC_PIN,board.INPUT,board.ANALOG,adc_callback)
        ''' ros loop '''
        rospy.spin()
    except rospy.ROSInterruptException: pass


开发者ID:mockbot,项目名称:MockBot,代码行数:29,代码来源:rospymata.py


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