Skip to content

Commit

Permalink
New key error fixed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
BCKM committed Aug 2, 2024
1 parent 5e7416a commit ad35f1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions mu/resources/neopia/02-01-02_Barami.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

n = Neosoco()
def on_press(key):
if key == '0':
if Keyboard.key_to_str(key) == '0':
n.motor_stop('right')
elif key == '1':
elif Keyboard.key_to_str(key) == '1':
n.motor_rotate('right', 'forward', '10')
elif key == '2':
elif Keyboard.key_to_str(key) == '2':
n.motor_rotate('right', 'forward', '50')
elif key == '3':
elif Keyboard.key_to_str(key) == '3':
n.motor_rotate('right', 'forward', '100')
elif key == Keyboard.ESC:
elif Keyboard.key_to_str(key) == Keyboard.ESC:
return False

Keyboard.read(on_press)
4 changes: 2 additions & 2 deletions mu/resources/neopia/04-04_Samosval_avtomobili.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
n = Neosoco()
n.servo_reset_degree('out1')
def on_press(key):
if key == '4':
if Keyboard.key_to_str(key) == '4':
n.servo_rotate_by_degree('out1', 'forward', '20', '60')
if key == '1':
if Keyboard.key_to_str(key) == '1':
n.servo_rotate_by_degree('out1', 'forward', '20', '0')
elif key == Keyboard.ESC:
return False
Expand Down

0 comments on commit ad35f1c

Please sign in to comment.