-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
007e9f1
commit 5a5b9cc
Showing
6 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from machine import Pin, PWM | ||
from time import sleep | ||
|
||
|
||
class LED: | ||
|
||
def __init__(self, pin_number: int, name: str): | ||
self.pin: Pin = Pin(pin_number, Pin.OUT) | ||
self.name = name | ||
|
||
def on(self): | ||
self.pin.on() | ||
|
||
def off(self): | ||
self.pin.off() | ||
|
||
def name(self) -> str: | ||
return self.name() | ||
|
||
def pin(self) -> Pin: | ||
return self.pin() | ||
|
||
def brighten(self, start_percent:int =0, end_percent:int =100, speed: int = 1)-> None: | ||
""" | ||
Starting from start_pct goes to end_pct over the course of speed | ||
:param intensity: | ||
:param speed: | ||
:return: | ||
""" | ||
pwm = PWM(self.pin()) | ||
pwm.freq(1000) | ||
start = int((65025 * start_percent) / 100) | ||
end = int((65025 * end_percent) / 100) | ||
|
||
for duty in range(start, end): | ||
pwm.duty_u16(duty) | ||
sleep(0.0001) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters