take_photo()

    steps += STEPS_PER_ROTATION
    if steps >= FULL_ROTATION:
        lock.release()
        return

    print "Starting next rotation: " + str(steps / STEP_MODE * 1.8) + "°"
    print
    stepper.set_steps(STEPS_PER_ROTATION)


if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    stepper = Stepper(UID_STEPPER, ipcon)  # Create device object
    iqr = IndustrialQuadRelay(UID_QUAD_RELAY, ipcon)

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    stepper.full_brake()
    stepper.disable()

    stepper.set_motor_current(1000)
    stepper.set_step_mode(STEP_MODE)
    stepper.set_max_velocity(100)

    stepper.set_speed_ramping(25, 25)

    stepper.register_callback(stepper.CALLBACK_POSITION_REACHED,
                              lambda x: cb_reached(stepper, ipcon, x))
Пример #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "ctG"  # Change to your UID

VALUE_A_ON = (1 << 0) | (1 << 2)  # Pin 0 and 2 high
VALUE_A_OFF = (1 << 0) | (1 << 3)  # Pin 0 and 3 high
VALUE_B_ON = (1 << 1) | (1 << 2)  # Pin 1 and 2 high
VALUE_B_OFF = (1 << 1) | (1 << 3)  # Pin 1 and 3 high

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_industrial_quad_relay import IndustrialQuadRelay

if __name__ == "__main__":
    ipcon = IPConnection()  # Create IP connection
    iqr = IndustrialQuadRelay(UID, ipcon)  # Create device object

    ipcon.connect(HOST, PORT)  # Connect to brickd
    # Don't use device before ipcon is connected

    iqr.set_monoflop(VALUE_A_ON, 15, 1500)
    # Set pins to high for 1.5 seconds

    ipcon.disconnect()