/pymata_aio_core_example Secret
Last active
October 3, 2015 02:19
Star
You must be signed in to star a gist
pymata_aio_core_example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is so cool. Awesome library. I can't wait to start playing around with this. Thanks!