Philip Howard | 4970f63 | 2013-03-28 01:10:16 +0000 | [diff] [blame] | 1 | # Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm |
Philip Howard | 859dda1 | 2013-03-28 17:26:27 +0000 | [diff] [blame] | 2 | # softPwm uses a fixed frequency |
Philip Howard | 4970f63 | 2013-03-28 01:10:16 +0000 | [diff] [blame] | 3 | import wiringpi2 |
Philip Howard | 859dda1 | 2013-03-28 17:26:27 +0000 | [diff] [blame] | 4 | |
| 5 | OUTPUT = 1 |
| 6 | |
| 7 | PIN_TO_PWM = 1 |
| 8 | |
Philip Howard | 4970f63 | 2013-03-28 01:10:16 +0000 | [diff] [blame] | 9 | wiringpi2.wiringPiSetup() |
Philip Howard | 859dda1 | 2013-03-28 17:26:27 +0000 | [diff] [blame] | 10 | wiringpi2.pinMode(PIN_TO_PWM,OUTPUT) |
| 11 | wiringpi2.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters |
Philip Howard | 4970f63 | 2013-03-28 01:10:16 +0000 | [diff] [blame] | 12 | |
| 13 | for time in range(0,4): |
Philip Howard | 859dda1 | 2013-03-28 17:26:27 +0000 | [diff] [blame] | 14 | for brightness in range(0,100): # Going from 0 to 100 will give us full off to full on |
| 15 | wiringpi2.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle |
Philip Howard | 4970f63 | 2013-03-28 01:10:16 +0000 | [diff] [blame] | 16 | wiringpi2.delay(10) # Delay for 0.2 seconds |
| 17 | for brightness in reversed(range(0,100)): |
Philip Howard | 859dda1 | 2013-03-28 17:26:27 +0000 | [diff] [blame] | 18 | wiringpi2.softPwmWrite(PIN_TO_PWM,brightness) |
Philip Howard | 4970f63 | 2013-03-28 01:10:16 +0000 | [diff] [blame] | 19 | wiringpi2.delay(10) |