Skip to content

Commit f7fcbd2

Browse files
committed
Minor corrections
1 parent fe4dcd0 commit f7fcbd2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

led-pwm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
#-----------------------------------------------------------------------------#
1818

1919
import time
20-
from machine import Pin, PWM
20+
from machine import Pin,PWM
2121

2222
pwm = PWM(Pin(15))
2323

2424
pwm.freq(1000)
2525

2626
while True:
27-
27+
2828
# Loop brightness from min to max
29-
for duty in range(65025):
29+
for duty in range(65535):
3030
pwm.duty_u16(duty)
31-
time.sleep_ms(0.1)
31+
time.sleep_us(5)
3232
# Loop brightness from max to min
3333
for duty in range(65025, 0, -1):
3434
pwm.duty_u16(duty)
35-
time.sleep_ms(0.1)
35+
time.sleep_us(5)

potentiometer-led.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#-----------------------------------------------------------------------------#
1818

1919
import time
20-
from machine import Pin,ADC
20+
from machine import Pin,ADC,PWM
2121

2222
# Define GPIO pins our hardware is connected to
2323
ADC_GPIO = 27
@@ -37,7 +37,7 @@
3737
adc_val = adc_obj.read_u16()
3838

3939
# Set PWM duty value to ADC value
40-
pwm.duty_u16(adc_value)
40+
pwm.duty_u16(adc_val)
4141

4242
# Wait 1 second
4343
time.sleep(1)

0 commit comments

Comments
 (0)