print( '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + str(data)) async def latching(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 # await my_board.set_pin_mode(2, Constants.ANALOG, pin_callback, Constants.CB_TYPE_ASYNCIO) await my_board.set_pin_mode(2, Constants.ANALOG) await my_board.set_analog_latch(2, Constants.LATCH_GT, 500, latch_callback, Constants.CB_TYPE_ASYNCIO) while True: await asyncio.sleep(1) #value = await my_board.analog_read(2) #print(value) # 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(latching(board))
comport = args.com if args.log == 'True': log = True else: log = False ard_ip_addr = args.aIPaddr ard_ip_port = args.aIPport ard_handshake = args.handshake core = PymataCore(int(args.wait), float(args.sleep), log, comport, ard_ip_addr, ard_ip_port, ard_handshake) # core = PymataCore() core.start() # Signal handler to trap control C # noinspection PyUnusedLocal,PyUnusedLocal def _signal_handler(sig, frame): if core is not None: print('\nYou pressed Ctrl+C') task = asyncio.ensure_future(core.shutdown()) asyncio.get_event_loop().run_until_complete(task) sys.exit(1) signal.signal(signal.SIGINT, _signal_handler) signal.signal(signal.SIGTERM, _signal_handler) server = PymataIOT(core)
from pymata_aio.constants import Constants @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))