anchor.diff:        if (recording != null) recording.printUsage(gpio);
       });
     });
  +}
  +
  +DateTime get _now => new DateTime.now();
  +
  +_assertValue(Pin pin, int expectedValue) {
  +  DateTime end = _now.add(new Duration(milliseconds: 250));
  +  while (_now.isBefore(end)) {
  +    if (pin.value == expectedValue) return;
  +  }
  +  fail('Expected $expectedValue on $pin');
   }
   
   Future _delay(int milliseconds) async {
  
positive.code:     test('pulseWidth and digitalRead - software pwm gpio.3', () async {
        Pin sensorPin = gpio.pin(2, input)..pull = pullDown;
        Pin ledPin = gpio.pin(3, pulsed)..pulseWidth = 0;
        await _delay(5);
        expect(sensorPin.value, 0);
  
        // Increase and note threshold at which pin 0 state changes
        int thresholdUp = await _pwmUp(ledPin, sensorPin);
  
negative.code:   int thresholdDown;
    for (int pulseWidth = 1024; pulseWidth >= 0; pulseWidth -= 10) {
      ledPin.pulseWidth = pulseWidth;
      if (thresholdDown == null) await _delay(5);
      int value = sensorPin.value;
      if (thresholdDown == null && value == 0) thresholdDown = pulseWidth;
    }
  