#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "XYZ" # Change XYZ to the UID of your Hall Effect Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_hall_effect import BrickletHallEffect

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

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

    # Get current edge count without reset
    count = he.get_edge_count(False)
    print("Count: " + str(count))

    raw_input("Press key to exit\n") # Use input() in Python 3
    ipcon.disconnect()
Beispiel #2
0
HOST = "localhost"
PORT = 4223
UID = "XYZ"  # Change XYZ to the UID of your Hall Effect Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_hall_effect import BrickletHallEffect


# Callback function for edge count callback
def cb_edge_count(edge_count, value):
    print("Edge Count: " + str(edge_count))


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

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

    # Register edge count callback to function cb_edge_count
    he.register_callback(he.CALLBACK_EDGE_COUNT, cb_edge_count)

    # Set period for edge count callback to 0.05s (50ms)
    # Note: The edge count callback is only called every 0.05 seconds
    #       if the edge count has changed since the last call!
    he.set_edge_count_callback_period(50)

    raw_input("Press key to exit\n")  # Use input() in Python 3
    ipcon.disconnect()
Beispiel #3
0
 def create_instance(self, uid, ipcon):
     return BrickletHallEffect(uid, ipcon)
Beispiel #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "XYZ"  # Change XYZ to the UID of your Hall Effect Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_hall_effect import BrickletHallEffect

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

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

    # Get current edge count without reset
    edge_count = he.get_edge_count(False)
    print("Edge Count: " + str(edge_count))

    raw_input("Press key to exit\n")  # Use input() in Python 3
    ipcon.disconnect()
Beispiel #5
0
# -*- coding: utf-8 -*-

HOST = "localhost"
PORT = 4223
UID = "XYZ" # Change XYZ to the UID of your Hall Effect Bricklet

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_hall_effect import BrickletHallEffect

# Callback function for edge count callback
def cb_edge_count(edge_count, value):
    print("Edge Count: " + str(edge_count))

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

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

    # Register edge count callback to function cb_edge_count
    he.register_callback(he.CALLBACK_EDGE_COUNT, cb_edge_count)

    # Set period for edge count callback to 0.05s (50ms)
    # Note: The edge count callback is only called every 0.05 seconds
    #       if the edge count has changed since the last call!
    he.set_edge_count_callback_period(50)

    raw_input("Press key to exit\n") # Use input() in Python 3
    ipcon.disconnect()