Damien George
11 years ago
6 changed files with 57 additions and 19 deletions
@ -0,0 +1,15 @@ |
|||||
|
import pyb |
||||
|
|
||||
|
@micropython.native |
||||
|
def f1(n): |
||||
|
for i in range(n): |
||||
|
print(i) |
||||
|
|
||||
|
f1(4) |
||||
|
|
||||
|
@micropython.native |
||||
|
def f2(r): |
||||
|
for i in r: |
||||
|
print(i) |
||||
|
|
||||
|
f2(range(4)) |
@ -0,0 +1,8 @@ |
|||||
|
0 |
||||
|
1 |
||||
|
2 |
||||
|
3 |
||||
|
0 |
||||
|
1 |
||||
|
2 |
||||
|
3 |
@ -1,14 +1,15 @@ |
|||||
|
import pyb |
||||
|
|
||||
@micropython.native |
@micropython.native |
||||
def f(led, n): |
def f(led, n, d): |
||||
led.off() |
led.off() |
||||
i = 0 |
i = 0 |
||||
while i < n: |
while i < n: |
||||
|
print(i) |
||||
led.toggle() |
led.toggle() |
||||
d = pyb.delay |
pyb.delay(d) |
||||
d(50) # pyb.delay(50) doesn't work! |
|
||||
i += 1 |
i += 1 |
||||
print(i) |
|
||||
led.off() |
led.off() |
||||
|
|
||||
f(pyb.LED(1), 2) |
f(pyb.LED(1), 2, 150) |
||||
f(pyb.LED(2), 4) |
f(pyb.LED(2), 4, 50) |
||||
|
Loading…
Reference in new issue