File tree Expand file tree Collapse file tree 4 files changed +24
-0
lines changed
Expand file tree Collapse file tree 4 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ import pyb
2+ led = pyb .LED (4 )
Original file line number Diff line number Diff line change 1+ tick = 0 # counter variable
2+
3+ while True :
4+ if tick <= 3 :
5+ led .toggle ()
6+ #make sure the value of tick has a 0-9 range
7+ tick = (tick + 1 ) % 10
8+ pyb .delay (100 )
Original file line number Diff line number Diff line change 1+ import pyb
2+ led = pyb .LED (4 )
Original file line number Diff line number Diff line change 1+ tick = 0 # counter variable
2+
3+ while True :
4+ if tick < 40 :
5+ # self.tick % 20 gives a number 0 to 19
6+ # subtracting 9 makes it -9 to 10
7+ # abs maps it 9 to 0 to 10
8+ # subtracting from 10 maps it 1 to 10 to 0
9+ # multiplying by 25 scales it 25 to 250 to 0
10+ led .intensity ((10 - (abs ((tick % 20 ) - 9 ))) * 25 )
11+ tick = (tick + 1 ) % 100
12+ pyb .delay (10 )
You can’t perform that action at this time.
0 commit comments