blob: f7c72fda4c40288d9a17a82d3b3d59c6dc830dbd [file] [log] [blame]
Philip Howard4970f632013-03-28 01:10:16 +00001# Pulsates an LED connected to GPIO pin 1 with a suitable resistor 4 times using softPwm
Philip Howard859dda12013-03-28 17:26:27 +00002# softPwm uses a fixed frequency
Philip Howard4970f632013-03-28 01:10:16 +00003import wiringpi2
Philip Howard859dda12013-03-28 17:26:27 +00004
5OUTPUT = 1
6
7PIN_TO_PWM = 1
8
Philip Howard4970f632013-03-28 01:10:16 +00009wiringpi2.wiringPiSetup()
Philip Howard859dda12013-03-28 17:26:27 +000010wiringpi2.pinMode(PIN_TO_PWM,OUTPUT)
11wiringpi2.softPwmCreate(PIN_TO_PWM,0,100) # Setup PWM using Pin, Initial Value and Range parameters
Philip Howard4970f632013-03-28 01:10:16 +000012
13for time in range(0,4):
Philip Howard859dda12013-03-28 17:26:27 +000014 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 Howard4970f632013-03-28 01:10:16 +000016 wiringpi2.delay(10) # Delay for 0.2 seconds
17 for brightness in reversed(range(0,100)):
Philip Howard859dda12013-03-28 17:26:27 +000018 wiringpi2.softPwmWrite(PIN_TO_PWM,brightness)
Philip Howard4970f632013-03-28 01:10:16 +000019 wiringpi2.delay(10)