def isPressed(self): #Return True si le bouton du capteur est pressé, False sinon tension = getTension(self._voie_can) if tension > 2: return True else: return False
def getLuminosite(self): #return la tension mesuré en sortie du capteur GPIO.output(self._cmd, GPIO.HIGH) time.sleep(0.2) tension = getTension(self._voie_can) GPIO.output(self._cmd, GPIO.LOW) return tension
def getSon(self): #return en % la puissance sonore reçue par le capteur GPIO.output(self._digi1, GPIO.HIGH) GPIO.output(self._digi2, GPIO.HIGH) tension = getTension(self._voie_can) GPIO.output(self._digi1, GPIO.LOW) GPIO.output(self._digi2, GPIO.LOW) return tension * 20
def BlancOuNoir(self): # return 1 si Blanc, 2 si Noir GPIO.output(self._cmd, GPIO.HIGH) time.sleep(0.2) tension = getTension(self._voie_can) GPIO.output(self._cmd, GPIO.LOW) if (tension > self._valeur_limite): return 1 else: return 2