Skip to content

Instantly share code, notes, and snippets.

@MrYsLab
Last active March 15, 2019 20:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save MrYsLab/8b735813e413bf62b455 to your computer and use it in GitHub Desktop.
pymata_aio_pymata3_example
#!/usr/bin/env python3
from pymata_aio.pymata3 import PyMata3
from pymata_aio.constants import Constants
def pin_6_pwm_128():
"""
Set digital pin 6 as a PWM output and set its output value to 128
@return: No Value Returned.
"""
# instantiate the pymata_core API
board = PyMata3()
# set the pin mode
board.set_pin_mode(6, Constants.PWM)
board.analog_write(6, 128)
# wait for 3 seconds to see the LED lit
board.sleep(3)
# reset the board and exit
board.shutdown()
if __name__ == "__main__":
pin_6_pwm_128()
@metracy
Copy link

metracy commented Apr 14, 2018

Where do you set the com port the arduino is located on?

@fabaff
Copy link

fabaff commented Nov 27, 2018

board = PyMata3(com_port='/dev/ttyACM0')

See details.

@prjemian
Copy link

If you don't specify the port (leaving the default as com_port-None), then it will be automatically detected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment