def __init__(self): self.tcp_flag = False self.led = Led() self.adc = ADS7830() self.servo = Servo() self.buzzer = Buzzer() self.control = Control() self.sonic = Ultrasonic() self.control.Thread_conditiona.start()
def __init__(self, api_creds, frame_order_info): self.wp_rest_interface = WPRestInterface(wcapi=api_creds["wcapi"], wpapi=api_creds["wpapi"]) self.usb_camera = UsbCamera.UsbCamera(os.getcwd() + "/captures/", resolution=(1920, 1080)) self.usb_camera.remove_old_captures(days_old=3) self.buzzer = Buzzer.Buzzer(pin=18) self.photo_only_mode = False self.set_state("READY") self.frame_order_info = frame_order_info
def __init__(self): #Get initial time offset self.initial_time = time.time() * 1000.0 self.current_time = 0 #Define timer variables self.previous_start_up_time = 0 self.previous_data_read_time = 0 self.previous_buzzer_time = 0 self.previous_cut_time = 0 self.previous_beep_time = 0 #Define data read variable self.previous_IMU_read = 0 self.previous_GPS_read = 0 self.previous_BMP_read = 0 #Buzzer variables self.beep = 0 #0 = idle, 1 = on #GPS initial conditions self.locked = False self.initialPosition = [] self.boundary_cutdown = False #Initiate Peripherals self.buzzer = Buzzer.Buzzer( self.buzzer_pin1, self.buzzer_pin2, self.current_time, self.buzzer_start_time, self.altitude_threshold) #Create Buzzer Object self.CutDown = CutDown.CutDown(self.current_time, self.cut_down_pin, self.cut_time) #Create CutDown Object self.lsm = LSM303DLM.LSM303DLM() self.lsm.enableDefault() self.l3g = L3G4200D.L3G4200D() self.l3g.enableDefault() self.bmp = BMP085.BMP085() self.gps = GPS.GPS() #Create log files newpath = './log' if not os.path.exists(newpath): os.makedirs(newpath) self.imu_file = open(newpath + "/IMUData.txt", "w") self.bmp_file = open(newpath + "/BMPData.txt", "w") self.gps_file = open(newpath + "/GPSData.txt", "w") #temp variables, remove later self.previous_time_temp = 0 self.count = 0
def __init__(self): self.PWM = Motor() self.servo = Servo() self.led = Led() self.ultrasonic = Ultrasonic() self.buzzer = Buzzer() self.adc = Adc() self.light = Light() self.infrared = Line_Tracking() self.tcp_Flag = True self.sonic = False self.Light = False self.Mode = 'one' self.endChar = '\n' self.intervalChar = '#'
def setup(self): """Setup pins, calibrate sensors, initialize variables """ try: self.temp_sensor = Temperature(20, interrupt=True, log_data=True) self.motion_sensor = Ultrasonic() self.camera = PiCam() self.human_detector = Detector() self.flame_sensor = FlameSensor(21) self.sms_service = SMS() self.buzzer = Buzzer(23) #self.gas_sensor = GasSensor() #if any of this failed -> stop print("Setup complete.") return True except Exception as e: print("Setup Failed. {}".format(e)) return False
def __init__(self): self.headUpDownAngle = 90 self.headLeftRightAngle = 90 self.PWM = Motor() self.servo = Servo() self.horn = Buzzer() self.speed = 1000 # corrected servo positions # adjust these to suit your car # so head is front and centre at start self.headLRcorrect = -3 self.headUDcorrect = 4 self.reset_head() self.selector = DefaultSelector() # set true for mecanum wheels self.mecanum = False self.useLights = True self.led = Led() self.mouse = evdev.InputDevice('/dev/input/event1') self.keybd = evdev.InputDevice('/dev/input/event0') self.readingKeys = False self.led.colorWipe(self.led.strip, Color(0,0,0),0) self.brake = False self.reverse = False self.indicating = False self.leftTurn = False self.rightTurn = False self.moving = False self.indi_time = datetime.now() self.indi_off = True self.brake_time = datetime.now() self.brake_off = True atexit.register(self.keybd.ungrab) # Don't forget to ungrab the keyboard on exit! atexit.register(self.mouse.ungrab) self.keybd.grab() # Grab, i.e. prevent the keyboard from emitting original events.# self.mouse.grab() # This works because InputDevice has a `fileno()` method. self.selector.register(self.mouse, EVENT_READ) self.selector.register(self.keybd, EVENT_READ)
Left_IDR = adc.recvADC(0) print("The photoresistor voltage on the left is " + str(Left_IDR) + "V") Right_IDR = adc.recvADC(1) print("The photoresistor voltage on the right is " + str(Right_IDR) + "V") Power = adc.recvADC(2) print("The battery voltage is " + str(Power * 3) + "V") time.sleep(1) print '\n' except KeyboardInterrupt: print "\nEnd of program" from Buzzer import * buzzer = Buzzer() def test_Buzzer(): try: buzzer.run('1') time.sleep(1) print "1S" time.sleep(1) print "2S" time.sleep(1) print "3S" buzzer.run('0') print "\nEnd of program" except KeyboardInterrupt: buzzer.run('0')
# Capture SIGINT for cleanup when the script is aborted def end_read(signal, frame): global continue_reading print "" continue_reading = False GPIO.cleanup() # Hook the SIGINT signal.signal(signal.SIGINT, end_read) # Create an object of the class MFRC522 MIFAREReader = MFRC522.MFRC522() # Create an object of the class Buzzer buzzer = Buzzer.Buzzer(15) # Welcome message print bcolors.WARNING + "Press Ctrl-C to stop...\n" + bcolors.ENDC # This loop keeps checking for chips. If one is near it will get the UID and authenticate while continue_reading: # Scan for cards (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) time.sleep(0.1) # If a card isn't found if status != MIFAREReader.MI_OK: continue
def Run_Cart4(self): #------------------------------------------Ultrasonic sensor and Servo Motor Class self.Ultrasonic = Ultrasonic() self.LED = Led() self.Buzzer = Buzzer() self.Junction = 0 #-------------------------------------------------------------------------------------- while True: self.Movement_Type = 0 Distance = self.Ultrasonic.get_distance() IR_Left = GPIO.input(IR01) IR_Mid = GPIO.input(IR02) IR_Right = GPIO.input(IR03) if (Distance > 15.0): if ((IR_Left == 0) and (IR_Mid == 1) and (IR_Right == 0)): if (self.Moved_Reverse_New != self.Moved_Reverse_Old): self.Movement_Type = 11 #Move Reverse else: self.Movement_Type = 5 #Move Forward self.Junction = 0 #Clear the Junction Variable elif ((IR_Left == 1) and (IR_Mid == 0) and (IR_Right == 0)): self.Movement_Type = 3 #Take Slight Left elif ((IR_Left == 1) and (IR_Mid == 1) and (IR_Right == 0)): self.Movement_Type = 3 #Take Slight Left elif ((IR_Left == 0) and (IR_Mid == 0) and (IR_Right == 1)): self.Movement_Type = 7 #Take Slight Right elif ((IR_Left == 0) and (IR_Mid == 1) and (IR_Right == 1)): self.Movement_Type = 7 #Take Slight Right elif ((IR_Mid == 1) and (IR_Left == 1) and (IR_Right == 1)): if (self.Junction == 0): self.Movement_Type = self.Mov_According_To_Specified_position( ) self.Junction = 1 else: pass else: self.Movement_Type = 0 #Stop Movement self.LED.ledIndex(0x20, 255, 125, 0) #Orange self.LED.ledIndex(0x40, 255, 125, 0) #Orange time.sleep(1) self.LED.ledIndex(0x60, 0, 0, 0) #Actuate the motors to move cart to the specific Coordinate self.Move_Cart(self.Movement_Type) if (self.Is_Intermediate_DestinTion_Reached()): break
def buzzer(): Buzzer.Buzzer(13).alarm_bg(5) return redirect('/')
import Buzzer from time import sleep import json with open('notes.json') as f: notes = json.load(f) b = Buzzer.Buzzer(18) b.set_duty_cycle(.1) seq = ((notes['E4'], .5), (notes['D4'], .5), (notes['C4'], 1)) b.playSequence(seq) b.loadNotes('notes.json') seq = (('E4', .5), ('D4', .5), ('C4', 1), ('B3', 1)) b.playNotes(seq)
def __init__(self, pin, pinBuzzer, duration, frequency): self.pin = pin self.handler = None self.state = False self.buzzer = Buzzer.Buzzer(pinBuzzer, duration, frequency)
time.sleep(0.05) if __name__ == '__main__': print('Initialize gamepad control...') myPad = gamepad.Gamepad() myPad.set_scale(.05, 800, .95, 4095) print('Initialize motor control...') myEngine = Motor.Motor() print('Initialize servo control ... ') myServo = ServoControl(debug = True) print('Initialize Buzzer Driver...') myBuzzer = Buzzer.Buzzer() print('Initialize ADC Driver...') myAdc = ADC.Adc() Thread_Monitor = threading.Thread(target = monitorBattery, args=[myAdc, myBuzzer]) Thread_Monitor.start() print('Initialize LED Driver...') myLed = Led.Led() try: print('Center camera head...') myServo.center() time.sleep(2) print('Enter 50ms control loop...')