def Gripper(): for i in range(0, steps): setStep(0, 1, 1, 0) sleep(delay) setStep(0, 1, 0, 1) sleep(delay) setStep(1, 0, 0, 1) sleep(delay) setStep(1, 0, 1, 0) sleep(delay) sleep(1) #sekundy servo.SetAngle(0) sleep(2) #sekundy for i in range(0, steps): setStep(1, 0, 1, 0) sleep(delay) setStep(1, 0, 0, 1) sleep(delay) setStep(0, 1, 0, 1) sleep(delay) setStep(0, 1, 1, 0) sleep(delay) sleep(5) #sekundy
def view_store(request): client_access_token = '0bb7a3b7450f4159a441699a80ed6ade' dialogflow = Dialogflow(client_access_token=client_access_token) input_dict = convert(request.body) action = json.loads(input_dict)['queryResult']['action'] parameters = json.loads(input_dict)['queryResult']['parameters'] if request.method == "POST": if (action == 'goodnight'): Text = json.loads(input_dict)['queryResult']['fulfillmentMessages'][0]['text']['text'][0] Answer = json.loads(input_dict)['queryResult']['fulfillmentMessages'] ans = parameters['agree'] if ans == 'yes': mixer.init() mixer.music.load('/home/pi/Downloads/lalluby.mp3') mixer.music.play() if (action == 'stop_music'): Text = json.loads(input_dict)['queryResult']['fulfillmentMessages'][0]['text']['text'][0] Answer = json.loads(input_dict)['queryResult']['fulfillmentMessages'] mixer.music.stop() if (action == 'rotation'): Text = json.loads(input_dict)['queryResult']['fulfillmentMessages'][0]['text']['text'][0] Answer = json.loads(input_dict)['queryResult']['fulfillmentMessages'] if (action == 'brightness'): Text = json.loads(input_dict)['queryResult']['fulfillmentMessages'][0]['text']['text'][0] Answer = json.loads(input_dict)['queryResult']['fulfillmentMessages'] if (parameters['temp'] == 'cold'): color = 100 if (parameters['temp'] == 'warm'): color = 100 bright = parameters['bright'] print('Light') light.writeNumber(color, bright) if (action == 'up_down'): Text = json.loads(input_dict)['queryResult']['fulfillmentMessages'][0]['text']['text'][0] Answer = json.loads(input_dict)['queryResult']['fulfillmentMessages'] if parameters['up_down'] == 'up': angle = parameters['value'] if parameters['up_down'] == 'down': angle = -1 * parameters['value'] servo.SetAngle(angle) data = {'fulfillmentText': Text, 'fulfillmentMessages': Answer} return HttpResponse(json.dumps(data))
cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1) if (len(face_names) > 0): if (face_names[0] == "Tidak Dikenali"): denied() else: granted() waktu_pintu_terbuka = sekarang detect_mode = False else: neutral() if not detect_mode: if servoToggle == 180: servo.SetAngle(0) servoToggle = 0 lama = (sekarang - waktu_pintu_terbuka).seconds seven.hitung(lama) if lama >= 10: alertPintuTerbuka.play() else: if servoToggle == 0: servo.SetAngle(180) servoToggle = 180 seven.mati() cv2.putText(frame, waktu, (10, 30), cv2.FONT_HERSHEY_DUPLEX, 1.0, (255, 255, 255), 1) cv2.imshow('Webcam Output', frame)
def open(): servo.SetAngle(90) print("la porte est ouverte !")
def close(): servo.SetAngle(0) print("la porte est fermé !")
def close_door(): servo.SetAngle(180)
def open_door(): servo.SetAngle(0)
pi.set_mode(coil_A_1_pin, pigpio.OUTPUT) pi.set_mode(coil_A_2_pin, pigpio.OUTPUT) pi.set_mode(coil_B_1_pin, pigpio.OUTPUT) pi.set_mode(coil_B_2_pin, pigpio.OUTPUT) def setStep(w1, w2, w3, w4): #GPIO.output(coil_A_1_pin, w1) pi.write(coil_A_1_pin, w1) pi.write(coil_A_2_pin, w2) pi.write(coil_B_1_pin, w3) pi.write(coil_B_2_pin, w4) servo.SetAngle(30) def Gripper(): for i in range(0, steps): setStep(0, 1, 1, 0) sleep(delay) setStep(0, 1, 0, 1) sleep(delay) setStep(1, 0, 0, 1) sleep(delay) setStep(1, 0, 1, 0) sleep(delay) sleep(1) #sekundy servo.SetAngle(0)