本文整理汇总了Python中PyMata.pymata.PyMata.get_firmata_version方法的典型用法代码示例。如果您正苦于以下问题:Python PyMata.get_firmata_version方法的具体用法?Python PyMata.get_firmata_version怎么用?Python PyMata.get_firmata_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyMata.pymata.PyMata
的用法示例。
在下文中一共展示了PyMata.get_firmata_version方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ArduinoBoard
# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import get_firmata_version [as 别名]
class ArduinoBoard(object):
""" Represents an Arduino board. """
def __init__(self, port):
from PyMata.pymata import PyMata
self._port = port
self._board = PyMata(self._port, verbose=False)
def set_mode(self, pin, direction, mode):
""" Sets the mode and the direction of a given pin. """
if mode == 'analog' and direction == 'in':
self._board.set_pin_mode(pin,
self._board.INPUT,
self._board.ANALOG)
elif mode == 'analog' and direction == 'out':
self._board.set_pin_mode(pin,
self._board.OUTPUT,
self._board.ANALOG)
elif mode == 'digital' and direction == 'in':
self._board.set_pin_mode(pin,
self._board.OUTPUT,
self._board.DIGITAL)
elif mode == 'digital' and direction == 'out':
self._board.set_pin_mode(pin,
self._board.OUTPUT,
self._board.DIGITAL)
elif mode == 'pwm':
self._board.set_pin_mode(pin,
self._board.OUTPUT,
self._board.PWM)
def get_analog_inputs(self):
""" Get the values from the pins. """
self._board.capability_query()
return self._board.get_analog_response_table()
def set_digital_out_high(self, pin):
""" Sets a given digital pin to high. """
self._board.digital_write(pin, 1)
def set_digital_out_low(self, pin):
""" Sets a given digital pin to low. """
self._board.digital_write(pin, 0)
def get_digital_in(self, pin):
""" Gets the value from a given digital pin. """
self._board.digital_read(pin)
def get_analog_in(self, pin):
""" Gets the value from a given analog pin. """
self._board.analog_read(pin)
def get_firmata(self):
""" Return the version of the Firmata firmware. """
return self._board.get_firmata_version()
def disconnect(self):
""" Disconnects the board and closes the serial connection. """
self._board.reset()
self._board.close()
示例2: PyMata
# 需要导入模块: from PyMata.pymata import PyMata [as 别名]
# 或者: from PyMata.pymata.PyMata import get_firmata_version [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
firmata.set_digital_latch(BUTTON_SWITCH, firmata.DIGITAL_LATCH_HIGH)