Closed sys49152 closed 10 years ago
HI Josef, I would be happy to answer your question. First, please make sure you are using version 1.58 of PyMata and that you loaded the FirmataPlus sketch onto your Arduino. Also, the only board that is currently supported for encoders is the Uno. It will not work on most other boards.
Here is the sketch I used to configure and read an encoder that I have connected to digital pins 14 and 15 (I am treating A0 and A1 as digital pins).
Just change the pin numbers for your setup and the com port you are using.
Please let me know if you have any other questions. Alan
# encoder test script
from PyMata.pymata import PyMata
encoder_pin_a = 14
encoder_pin_b = 15
# Create a PyMata instance using the Arduino COM Port as the input parameter
firmata = PyMata("/dev/ttyACM0")
# Configure
firmata.set_pin_mode(encoder_pin_a, firmata.INPUT, firmata.ENCODER)
firmata.set_pin_mode(encoder_pin_b, firmata.INPUT, firmata.ENCODER)
firmata.encoder_config(encoder_pin_a, encoder_pin_b)
# The current value
while (1):
print(firmata.digital_read(encoder_pin_a))
I just updated the formatting of my reply to make the code readable.
Thank You.
Best Regards Josef AKA sys49152
On Mon, Jul 14, 2014 at 5:41 PM, Alan Yorinks notifications@github.com wrote:
Closed #3 https://github.com/MrYsLab/PyMata/issues/3.
— Reply to this email directly or view it on GitHub https://github.com/MrYsLab/PyMata/issues/3#event-141279469.
Hello I would like to know how to use PyMata to read data form a rotary encoder. I was only able to find the encoder_config in the API which is not helpful enough for me. Can you give me a brief example how to initialize the rotary encoder and how to get the values (direction and steps)? That will help me a lot.
Thank you in advance Josef AKA sys49152