Skip to content

Commit 75cadad

Browse files
authored
Add files via upload
1 parent 49805c2 commit 75cadad

27 files changed

+190
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Add your Python code here. E.g.
2+
from microbit import *
3+
# Servo control:
4+
# 100 = 1 millisecond pulse all right
5+
# 200 = 2 millisecond pulse all left
6+
# 150 = 1.5 millisecond pulse center
7+
# 10 is 10 milliseconds for period 1/100 Hz
8+
while True:
9+
pin1.set_analog_period(10)
10+
pin1.write_analog(100)
11+
sleep(1000)
12+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Add your Python code here. E.g.
2+
from microbit import *
3+
import time
4+
# Servo control:
5+
# 100 = 1 millisecond pulse all right
6+
# 200 = 2 millisecond pulse all left
7+
# 150 = 1.5 millisecond pulse center
8+
# 10 is 10 milliseconds for period 1/100 Hz
9+
turns = 5
10+
while True:
11+
pin1.set_analog_period(50)
12+
if turns > 0:
13+
pin1.write_analog(100)
14+
sleep(2000)
15+
turns = turns - 1
16+
else:
17+
pin1.write_analog(0)
18+
19+
20+
21+
22+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add your Python code here. E.g.
2+
from microbit import *
3+
import time
4+
# Servo control:
5+
# 100 = 1 millisecond pulse all right
6+
# 200 = 2 millisecond pulse all left
7+
# 150 = 1.5 millisecond pulse center
8+
# 10 is 10 milliseconds for period 1/100 Hz
9+
pin1.set_analog_period(10)
10+
11+
while True:
12+
13+
if button_a.is_pressed():
14+
display.clear()
15+
pin1.write_analog(200)
16+
sleep(2000)
17+
pin1.write_analog(0)
18+
elif button_b.is_pressed():
19+
display.clear()
20+
pin1.write_analog(100)
21+
sleep(2000)
22+
pin1.write_analog(0)
23+
else:
24+
display.show(Image.ASLEEP)
25+
668 KB
Binary file not shown.
3.01 MB
Binary file not shown.
61.8 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Add your Python code here. E.g.
2+
from microbit import *
3+
# Servo control:
4+
# 100 = 1 millisecond pulse all right
5+
# 200 = 2 millisecond pulse all left
6+
# 150 = 1.5 millisecond pulse center
7+
# 10 is 10 milliseconds for period 1/100 Hz
8+
while True:
9+
pin1.set_analog_period(10)
10+
pin1.write_analog(150)
11+
sleep(1000)
12+
pin1.write_analog(100)
13+
sleep(1000)
14+
pin1.write_analog(150)
15+
sleep(1000)
16+
pin1.write_analog(200)
17+
sleep(1000)
18+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Add your Python code here. E.g.
2+
from microbit import *
3+
import time
4+
# Servo control:
5+
# 100 = 1 millisecond pulse all right
6+
# 200 = 2 millisecond pulse all left
7+
# 150 = 1.5 millisecond pulse center
8+
# 10 is 10 milliseconds for period 1/100 Hz
9+
pin1.set_analog_period(10)
10+
11+
while True:
12+
if button_a.is_pressed():
13+
display.clear()
14+
pin1.write_analog(200)
15+
sleep(2000)
16+
pin1.write_analog(0)
17+
elif button_b.is_pressed():
18+
display.clear()
19+
pin1.write_analog(100)
20+
sleep(2000)
21+
pin1.write_analog(0)
22+
else:
23+
display.show(Image.ASLEEP)
24+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Add your Python code here. E.g.
2+
from microbit import *
3+
import time
4+
# Servo control:
5+
# 100 = 1 millisecond pulse all right
6+
# 200 = 2 millisecond pulse all left
7+
# 150 = 1.5 millisecond pulse center
8+
# 10 is 10 milliseconds for period 1/100 Hz
9+
pin1.set_analog_period(10)
10+
11+
while True:
12+
if button_a.is_pressed():
13+
display.clear()
14+
pin1.write_analog(200)
15+
sleep(250)
16+
pin1.write_analog(0)
17+
elif button_b.is_pressed():
18+
display.clear()
19+
pin1.write_analog(100)
20+
sleep(250)
21+
pin1.write_analog(0)
22+
else:
23+
display.show(Image.ASLEEP)
24+
448 KB
Binary file not shown.

0 commit comments

Comments
 (0)