def runUltrasonic(): us = UltrasonicClass.Ultrasonic() while True: try: print(us.getDistance()) time.sleep(30) except KeyboardInterrupt: break us.Cleanup()
def CheckDosing(threshold): us = UltrasonicClass.Ultrasonic() try: if (us.getDistance() < threshold): return False else: return True except KeyboardInterrupt: pass
def runUltrasonic(distanceQueue): us = UltrasonicClass.Ultrasonic() while True: try: distanceQueue.put_nowait(us.getDistance()) #print(us.getDistance()) time.sleep(2) except KeyboardInterrupt: break us.Cleanup()
selectedPain = pains[i] else: pass for i in range(0, len(outings)): # Searching minimum Outing Time if Outinglist[i][1] <= minimumOut: minimumOut = Outinglist[i][1] selectedOut = outings[i] if (selectedPain == input_selectedPain and selectedOut == input_selectedOut): return False else: return True if __name__ == '__main__': us = UltrasonicClass.Ultrasonic( ) #method list : getDistance, Cleanup // this syntax is like " UltrasonicClass.UltraSonic us = new UltrasonicClass.Ultrasonic()" in JAVA sm = StepClass.StepMotor() #method list : step fcm = firebase.FirebaseApplication("https://ddoyak-362cb.firebaseio.com/", None) #fcm database object push_service = FCMNotification( api_key= "AAAANJ-9vtU:APA91bGKUyUHMY0Rj32m9FhP4eFJTP-9xwFmSHjkTqJDmmDEmZL5tJOtJ2PvrAwL5jBErjs8uC9pjE8WRua1Iooakul7lACDwAvgYg8n5r3Jfix8Ggcw89KXVQ50UCgg-hCbPj7_uaddOsNd09fk4q-eWbt0sW2G7A" ) pygame.mixer.init() pygame.mixer.music.load("ifonger.mp3") mode = True # true:time check , false:distance check(whether user dose medicine) threshold = 9.5 # threshold of ultrasonic sensor value while True: pains = fcm.get("/DOSE", None).keys(
def rotate(self, count): pas = 0 self.step_4(0) self.steps_4(count * 2100) def step(self): pas = 0 self.step_4(0) self.steps_4(257) def rstep(self): pas = 0 self.step_4(0) self.steps_4(-370) if __name__ == '__main__': us = UltrasonicClass.Ultrasonic() print(us.getDistance()) sm = StepMotor() pygame.mixer.init() pygame.mixer.music.load("ifonger.mp3") sm.step() time.sleep(5) sm.step() pygame.mixer.music.play() while pygame.mixer.music.get_busy() == True: continue time.sleep(1) print(us.getDistance())