Jump to content

ben_bienne

Members
  • Gesamte Inhalte

    9
  • Benutzer seit

  • Letzter Besuch

ben_bienne's Achievements

Newbie

Newbie (1/14)

0

Reputation in der Community

  1. Thank you for the help! It work's! Here is the complete code #!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "ksc" # Change to your UID es = "he6" # Change to your UID from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_motion_detector import MotionDetector from tinkerforge.bricklet_io4 import IO4 import time system_activ = True def cb_interrupt(interrupt_mask, value_mask): global system_activ # test if interrupt is from pin 0 if interrupt_mask & (1 << 0): # test if button is pressed or released if value_mask & (1 << 0): print "button released" else: print "button pressed" if system_activ: system_activ = False print ("surveillance is disabled ", +system_activ) else: system_activ = True print ("surveillance is enabled ", +system_activ) # Callback function for end of detection cycle def cb_detection_cycle_ended(): if not system_activ: return print('Detection Cycle Ended (next detection possible in ~3 seconds)') # Callback function for detected motion def cb_motion_detected(): if not system_activ: return print('Motion Detected') if __name__ == "__main__": ipcon = IPConnection() # Create IP connection md = MotionDetector(UID, ipcon) # Create device object io = IO4(es, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Register callback for interrupts io.register_callback(io.CALLBACK_INTERRUPT, cb_interrupt) # Enable interrupt on pin 0 and pin 1 io.set_interrupt(1 << 0 ) # Register detected callback to function cb_motion_detected md.register_callback(md.CALLBACK_MOTION_DETECTED, cb_motion_detected) # Register detection cycle ended callback to function cb_detection_cycle_ended md.register_callback(md.CALLBACK_DETECTION_CYCLE_ENDED, cb_detection_cycle_ended) raw_input('Press key to exit\n') # Use input() in Python 3 ipcon.disconnect()
  2. Hi all, Actually I use a Motion Detector and Raspberry Pi with camera to take picture when something is moving. It work good. I can switch on/off the Motion Detector with my computer keyboard Now I would like to do the same without my keyboard and screen but with a manual switch. I have an IO4 Bricklet and a button ON/OFF. I am new in programming and I don't find the way to do this. Can someone help me. Here is my python code #!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "ksc" # Change to your UID from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_motion_detector import MotionDetector import picamera import time camera_name = "cameraA_" # Callback function for end of detection cycle def cb_detection_cycle_ended(): if not system_activ: return print('Detection Cycle Ended (next detection possible in ~3 seconds)') # Callback function for detected motion def cb_motion_detected(): if not system_activ: return print('Motion Detected') with picamera.PiCamera() as camera: date_time = int(time.time()) date_string = str(date_time) camera.resolution = (1024, 768) camera.start_preview() # Camera warm-up time time.sleep(2) camera.capture(camera_name + date_string +".jpg") if __name__ == "__main__": ipcon = IPConnection() # Create IP connection md = MotionDetector(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd system_activ = True # Don't use device before ipcon is connected # Register detected callback to function cb_motion_detected md.register_callback(md.CALLBACK_MOTION_DETECTED, cb_motion_detected) # Register detection cycle ended callback to function cb_detection_cycle_ended md.register_callback(md.CALLBACK_DETECTION_CYCLE_ENDED, cb_detection_cycle_ended) while True: print "Select an option:" print "1. Turn surveillance off" if system_activ is True else "1. Turn surveillance on" print "0. Exit" option = int(raw_input("Option: ")) if option == 0: break elif option == 1: if system_activ: system_activ = False print "Surveillance is disabled" else: system_activ = True print "Surveillance is enabled" else: print "Invalid input!" # raw_input('Press key to exit\n') # Use input() in Python 3 ipcon.disconnect() Thank's in advance
  3. Besten Dank für die Hilfe und Entschuldingung für die spätere Antwort. Ich habe mein Zähler mit eine IO4 und 7 segment display gemacht. #!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "he6" # Change to your UID dis = "kTk" # Change to your UID DIGITS = [0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71] # // 0~9,A,b,C,d,E,F from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_io4 import IO4 from tinkerforge.bricklet_segment_display_4x7 import SegmentDisplay4x7 import time if __name__ == "__main__": ipcon = IPConnection() # Create IP connection io = IO4(UID, ipcon) # Create device object sd4x7 = SegmentDisplay4x7(dis, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Set pin 1 to output low io.set_configuration(1 << 1, 'o', False) # Set pin 2 and 3 to output high io.set_configuration((1 << 2) | (1 << 3), 'o', True) try: io.set_edge_count_config(1, io.EDGE_TYPE_RISING, 1) ii = True while True: print('Edge count: {0}'.format(io.get_edge_count(0, ii))) compteur = format(io.get_edge_count(0, ii)) compteur_string = "0" +"0" +compteur string = str(compteur_string) sub1 = int(string[0]) sub2 = int(string[1]) sub3 = int(string[2]) if int(compteur) < 10 : segments = (DIGITS[0], DIGITS[sub1], DIGITS[sub2], DIGITS[sub3]) sd4x7.set_segments(segments, 0, False) elif int(compteur) >= 10: sub4 = int(string[3]) segments = (DIGITS[sub1], DIGITS[sub2], DIGITS[sub3], DIGITS[sub4]) sd4x7.set_segments(segments, 0, False) elif int(compteur) >= 100: sub5 = int(string[4]) segments = (DIGITS[sub2], DIGITS[sub3], DIGITS[sub4], DIGITS[sub5]) sd4x7.set_segments(segments, 0, False) time.sleep(0.5) ii = False finally: ipcon.disconnect() Schöne Grüsse
  4. Das Problem liegt an meinem Laptop (Debian Whezzy). Es funktionniert mit einem Raspberry Pi und einem Laptop mit OSX
  5. Hallo, Nein Master und PC sind direkt angeschlossen dmesg [ 392.223299] usb 3-1.2: USB disconnect, device number 3 [ 392.420692] usb 3-1.2: new full-speed USB device number 4 using ehci_hcd [ 392.514900] usb 3-1.2: New USB device found, idVendor=16d0, idProduct=063d [ 392.514910] usb 3-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 392.514917] usb 3-1.2: Product: Master Brick [ 392.514921] usb 3-1.2: Manufacturer: Tinkerforge GmbH [ 392.514926] usb 3-1.2: SerialNumber: 68UwxS [ 392.624600] usb 3-1.2: reset full-speed USB device number 4 using ehci_hcd
  6. Ich habe das neue firmware rein getan. Das Problem steht immer noch.
  7. Hallo, Danke für die Antwort. Die Schaltspannung ist 230V. Der Schütz ist ein Telemecanique LC1D32 Zur Zeit ist nur die Steuerung angeschlossen. Er soll ein Ventilateur (400V) steuern. Entschuldigung für die Qualität den Photos ich hoffe auch das mein Deutsch verständlich ist. Gruss
  8. Hallo, Ich möchten einen Schütz von Télémacanique mit einem DualRelay ein und ausschalten. Bei der Einschaltung ist kein Problem aber bei der Auschaltung das Master Brick reboot automatisch. Was mache ich falsch
×
×
  • Neu erstellen...