blob: e4bf0b3166b54129ebcdd399c46e7f0f2a64e2d2 [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
Phil Howard6577b7e2016-03-09 12:19:22 +00003import wiringpi
Philip Howard859dda12013-03-28 17:26:27 +00004
5OUTPUT = 1
6
7PIN_TO_PWM = 1
8
Phil Howard6577b7e2016-03-09 12:19:22 +00009wiringpi.wiringPiSetup()
10wiringpi.pinMode(PIN_TO_PWM,OUTPUT)
11wiringpi.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
Phil Howard6577b7e2016-03-09 12:19:22 +000015 wiringpi.softPwmWrite(PIN_TO_PWM,brightness) # Change PWM duty cycle
16 wiringpi.delay(10) # Delay for 0.2 seconds
Philip Howard4970f632013-03-28 01:10:16 +000017 for brightness in reversed(range(0,100)):
Phil Howard6577b7e2016-03-09 12:19:22 +000018 wiringpi.softPwmWrite(PIN_TO_PWM,brightness)
19 wiringpi.delay(10)