Skip to content

Instantly share code, notes, and snippets.

@MrYsLab
Last active October 3, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrYsLab/df8ec22ea16de6c84d67 to your computer and use it in GitHub Desktop.
Save MrYsLab/df8ec22ea16de6c84d67 to your computer and use it in GitHub Desktop.
pymata_aio_core_example
#!/usr/bin/env python3
from pymata_aio.pymata_core import PymataCore
from pymata_aio.constants import Constants
import asyncio
@asyncio.coroutine
def pin_6_pwm_128(my_board):
"""
Set digital pin 6 as a PWM output and set its output value to 128
@param my_board: A PymataCore instance
@return: No Return Value
"""
# set the pin mode
yield from my_board.set_pin_mode(6, Constants.PWM)
# set the pin to 128
yield from my_board.analog_write(6, 128)
# let the led stay lit for 3 seconds
yield from asyncio.sleep(3)
# shutdown
yield from my_board.shutdown()
# create a PyMataCore instance and complete the initialization with a call to start()
board = PymataCore()
board.start()
# get the loop, and execute pin6_pwm_128
loop = asyncio.get_event_loop()
loop.run_until_complete(pin_6_pwm_128(board))
@wgwz
Copy link

wgwz commented Oct 3, 2015

This is so cool. Awesome library. I can't wait to start playing around with this. Thanks!

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