Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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 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