Пример #1
0
 def runTest(self):
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(LED_PIN, GPIO.OUT)
     pwm = GPIO.PWM(LED_PIN, 50)
     with self.assertRaises(RuntimeError):
         pwm2 = GPIO.PWM(LED_PIN, 49)
     GPIO.cleanup()
Пример #2
0
def issue_94(cycles):
    # led flickers.  Bug = LED stays off at around cycle 400
    pwm = GPIO.PWM(LED_PIN, 1)
    for i in xrange(cycles):
        print(i)
        pwm.ChangeFrequency(25)
        pwm.start(50)
        time.sleep(1)
        pwm.stop()
Пример #3
0
def issue_154():
    # fails with led off at around 400
    count = 0
    pinRef = GPIO.PWM(LED_PIN, 50)  # create new PWM instance
    while True:
        pinRef.start(10)  # update PWM value
        time.sleep(0.05)
        pinRef.stop()
        GPIO.output(LED_PIN, 0)
        time.sleep(0.05)
        count = count + 1
        print count
Пример #4
0
 def runTest(self):
     GPIO.setmode(GPIO.BOARD)
     GPIO.setup(LED_PIN, GPIO.OUT)
     pwm = GPIO.PWM(LED_PIN, 50)
     pwm.start(100)
     print("\nPWM tests")
     response = input('Is the LED on (y/n) ? ').upper()
     self.assertEqual(response, 'Y')
     pwm.start(0)
     response = input('Is the LED off (y/n) ? ').upper()
     self.assertEqual(response, 'Y')
     print("LED Brighten/fade test...")
     for i in range(0, 3):
         for x in range(0, 101, 5):
             pwm.ChangeDutyCycle(x)
             time.sleep(0.1)
         for x in range(100, -1, -5):
             pwm.ChangeDutyCycle(x)
             time.sleep(0.1)
     pwm.stop()
     response = input('Did it work (y/n) ? ').upper()
     self.assertEqual(response, 'Y')
     GPIO.cleanup()