import math

class HCSR04:
    def __init__(self, pinTrigger, pinEcho):
        self.f = lambda x: 1.0 + 30 * (math.sin(x))**2
        self.x = 0.0

    def __iter__(self):
        while True:
            yield self.llegeix()

    def llegeix(self):
        r = self.f(self.x)
        self.x = self.x + 0.5
        return r

    def tanca(self):
        pass

