pyFirmata (բացատրագիր)

Post Reply
davbaghdasaryan
Posts: 101
Joined: Thu Apr 09, 2020 8:08 pm

pyFirmata (բացատրագիր)

Post by davbaghdasaryan »

pyFirmata (բացատրագիր)


Ներբեռնում
Ամենանախընտրելի ներբեռման տարբերակը pip - ի միջոցով է։

Code: Select all

pip install pyfirmata
Եթե այն ցանկանում եք ներբեռնել «python setup.py install» - ի միջոցով, ապա պետք է ներբեռնել նաև «pyserial» ը։
Կիրառում
Հիմնական գաղափար

Code: Select all

>>> from pyfirmata import Arduino, util
>>> board = Arduino('/dev/tty.usbserial-A6008rIF')
>>> board.digital[13].write(1)
Անալոգ pin-երի հետ աշխատելու համար անհրաժեշտ է օգտագործել «iterator» կապը։ Հակառակ դեպքում սալիկը կշարունակի տվյալներ ուղարկել ձեր սերիային, քանի դեռ այն չի լցվում։

Code: Select all

>>> it = util.Iterator(board)
>>> it.start()
>>> board.analog[0].enable_reporting()
>>> board.analog[0].read()
0.661440304938
Եթե ավելի հաճախ եք pin-եր օգտագործում, ապա անհրաժեշտ է օգտագործել «get_pin» մեթոդը: Եկեք փորձենք մեզ անհրաժեշտ pin-երը ներմուծել տողի տեսքով։ Ունենք (1 : 2 : 3) կառուցվածք, որտեղ․

1) a - analog
d - digital

2) ցանկացած pin-ի համարը։

3) i - input
o – output
Օրինակ «a:0:i» համար անալոգային 0, որպես մուտքագրման կամ «d: 3: p»` թվային pin 3-ի համար որպես pwm .:

Code: Select all

>>> analog_0 = board.get_pin('a:0:i')
>>> analog_0.read()
0.661440304938
>>> pin3 = board.get_pin('d:3:p')
>>> pin3.write(0.6)
Հավելյալ նյութեր

davbaghdasaryan
Posts: 101
Joined: Thu Apr 09, 2020 8:08 pm

pyFirmata (описание)

Post by davbaghdasaryan »

pyFirmata (описание)
Загрузка:
Наиболее предпочтительный вариант загрузки - через pip.

Code: Select all

pip install pyfirmata
Если вы хотите загрузить через "python setup.py install", вы также должны загрузить "pyserial".
Применение:
Основная идея

Code: Select all

>>> from pyfirmata import Arduino, util
>>> board = Arduino('/dev/tty.usbserial-A6008rIF')
>>> board.digital[13].write(1)
Для работы с аналоговыми pin-ами необходимо использовать соединение “iterator”. В противном случае плата будет продолжать отправлять данные на вашу серию, пока она не будет заполнена.

Code: Select all

>>> it = util.Iterator(board)
>>> it.start()
>>> board.analog[0].enable_reporting()
>>> board.analog[0].read()
0.661440304938
Если вы чаще используете pin-ы, вам нужно использовать метод "get_pin". Попробуем ввести нужные нам pin-ы в виде строки. У нас есть структура (1: 2: 3), где

1) a - analog
d - digital

2) номер любого pin-а

3) i - input
o – output.
Например аналоговый 0 для "a:0:i" в качестве входа или "d: 3: p" для цифрового pin 3 в качестве pwm.

Code: Select all

>>> analog_0 = board.get_pin('a:0:i')
>>> analog_0.read()
0.661440304938
>>> pin3 = board.get_pin('d:3:p')
>>> pin3.write(0.6)
Дополнительные материалы:

davbaghdasaryan
Posts: 101
Joined: Thu Apr 09, 2020 8:08 pm

pyFirmata (documentation)

Post by davbaghdasaryan »

pyFirmata (documentation)


Download
Preferred download option is via “pip”

Code: Select all

pip install pyfirmata
If you want to download it via "python setup.py install", you must also download "pyserial".
Usage
Main idea

Code: Select all

>>> from pyfirmata import Arduino, util
>>> board = Arduino('/dev/tty.usbserial-A6008rIF')
>>> board.digital[13].write(1)
In order to work analog codes, an “iterator” link is required. Otherwise the breadboard will continue to send data to your batch until it is full.

Code: Select all

>>> it = util.Iterator(board)
>>> it.start()
>>> board.analog[0].enable_reporting()
>>> board.analog[0].read()
0.661440304938
If you use pin-s often the “get_pin” method is required to use. Let’s try to inport the pin-s we need as a line.
We have a (1 : 2 : 3) structure, where:


1) a - analog
d - digital

2) any pin number։

3) i - input
o – output
For example,analog 0 for “a:0:i” as an input or “d:3:p” for digital pin 3 as pwm.

Code: Select all

>>> analog_0 = board.get_pin('a:0:i')
>>> analog_0.read()
0.661440304938
>>> pin3 = board.get_pin('d:3:p')
>>> pin3.write(0.6)
See more:

Post Reply