コード例 #1
0
     :param adc: ADC number
     """

    # set the pin mode
    my_board.set_pin_mode_analog_input(adc,
                                       differential=10,
                                       callback=the_callback)

    print('Enter Control-C to quit.')
    try:
        time.sleep(5)
        print('Disabling reporting for 3 seconds.')
        my_board.disable_analog_reporting(adc)
        time.sleep(3)
        print('Re-enabling reporting.')
        my_board.enable_analog_reporting(adc)
        while True:
            time.sleep(5)
    except KeyboardInterrupt:
        board.shutdown()
        sys.exit(0)


board = telemetrix_rpi_pico.TelemetrixRpiPico()

try:
    analog_in(board, ADC)
except KeyboardInterrupt:
    board.shutdown()
    sys.exit(0)
コード例 #2
0
"""

import sys
import time

from telemetrix_rpi_pico import telemetrix_rpi_pico

"""
...

Recommended stepper homing procedure:

"""

# Create a Telemetrix instance.
board = telemetrix_rpi_pico.TelemetrixRpiPico(sleep_tune=.001) # the computer's response is up to 2-5x sleep_tune 

STEPPER_X = 0
STEPPER_Y = 1
board.stepper_new(STEPPER_X, dir_pin=10, step_pin=11, endswitch_pin=18, disable_pin=0, motor_inertia=32*4)
board.stepper_new(STEPPER_Y, dir_pin=12, step_pin=13, endswitch_pin=19, disable_pin=0, motor_inertia=32*4)

HOMING_DISTANCE = -25000 # slightly more than physical range of the motors



def triangular_path():
    yield(1000, 1000) # set motors to first corner...
    yield(1000, 9000) # in next callback, go to second corner...
    yield(3000, 9500) # etc.
    yield(1000, 1000) # ... and finish the triangle