def transfer(self, data): start = time() now = time() while now - start < 0.5: on = chargetimes.getLedResistor(receiveRate) if on: start = time() else: now = time() self.an2led(data, sendRate)
def transfer(self, data): start=time() now = time() while now-start < 0.5: on = chargetimes.getLedResistor(receiveRate) if on: start=time() else: now = time() self.an2led(data, sendRate)
import ledOnOff import chargetimes import time ledOnOff.on() time.sleep(0.001) print("Detect LED 'on': " + str(chargetimes.getLedResistor())) ledOnOff.off() time.sleep(0.001) print("Detect LED 'off': " + str(not chargetimes.getLedResistor()))
def receiveResistor(self): on = chargetimes.getLedResistor(receiveRate) return self.addOne(on, time())