Skip to content

Commit

Permalink
Refactor NeoSoco sample codes
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongJun-Lee committed Aug 18, 2024
1 parent 7e3ad42 commit 3cd59c1
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mu/resources/neopia/01-02_FutbolBot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

def on_press(key):
if key == Keyboard.UP:
n.motor_rotate('both', 'forward', '10')
Expand All @@ -14,5 +15,6 @@ def on_press(key):
n.motor_stop('both')
elif key == Keyboard.ESC:
return False


# Klaviaturning tugmachasini bosganda "on_press" funksiyasi chaqriladi
Keyboard.read(on_press)
1 change: 1 addition & 0 deletions mu/resources/neopia/01-06_Sehrli_ansanmbl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from neopia import *

n = Neosoco()

while True:
n.buzzer_by_port('in1')
wait(200)
Expand Down
1 change: 1 addition & 0 deletions mu/resources/neopia/02-01-01_Barami.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in3') < 30:
n.motor_stop('right')
Expand Down
2 changes: 2 additions & 0 deletions mu/resources/neopia/02-01-02_Barami.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from neopia import *

n = Neosoco()

def on_press(key):
if Keyboard.key_to_str(key) == '0':
n.motor_stop('right')
Expand All @@ -15,4 +16,5 @@ def on_press(key):
elif key == Keyboard.ESC:
return False

# Klaviaturning tugmachasini bosganda "on_press" funksiyasi chaqriladi
Keyboard.read(on_press)
1 change: 1 addition & 0 deletions mu/resources/neopia/02-03_Neo_kliner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in1') < 20:
n.motor_rotate('both', 'forward', '50')
Expand Down
1 change: 1 addition & 0 deletions mu/resources/neopia/02-04-01_Aqlli_avtomobil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in2') <= 7:
n.motor_move('backward')
Expand Down
1 change: 1 addition & 0 deletions mu/resources/neopia/02-04-02_Aqlli_avtomobil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from neopia import *

n = Neosoco()

while True:
n.motor_rotate('both', 'forward', 'in2')
n.buzzer_by_port('in2')
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in1') and n.get_value('in2') > 40:
n.motor_rotate('both', 'forward', '30')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in1') and n.get_value('in2') > 40:
n.motor_rotate('both', 'forward', '30')
Expand Down
1 change: 1 addition & 0 deletions mu/resources/neopia/04-01_Fonar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in1') == 255:
n.led_on('out1', '100')
Expand Down
1 change: 1 addition & 0 deletions mu/resources/neopia/04-03-01_Aqlli_avtomobil_2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in2') <= 10:
n.motor_stop('both')
Expand Down
1 change: 1 addition & 0 deletions mu/resources/neopia/04-03-02_Aqlli_avtomobil_2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

# Masofa sensor orqali to‘siqni tekshirish uchun funksiya yaratish
def servo_motor():
n.motor_stop('both')
Expand Down
2 changes: 2 additions & 0 deletions mu/resources/neopia/04-04_Samosval_avtomobili.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

n = Neosoco()
n.servo_reset_degree('out1')

def on_press(key):
if Keyboard.key_to_str(key) == '4':
n.servo_rotate_by_degree('out1', 'forward', '20', '60')
Expand All @@ -10,4 +11,5 @@ def on_press(key):
elif key == Keyboard.ESC:
return False

# Klaviaturning tugmachasini bosganda "on_press" funksiyasi chaqriladi
Keyboard.read(on_press)
1 change: 1 addition & 0 deletions mu/resources/neopia/04-05_Robot_qol.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from neopia import *

n = Neosoco()

while True:
if n.get_value('in1') < 80 and n.get_value('in2') < 80:
n.servo_stop('out1')
Expand Down
2 changes: 2 additions & 0 deletions mu/resources/neopia/04-06_Konveyer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from neopia import *

n = Neosoco()

n.servo_reset_degree('out1')
n.motor_rotate('both', 'forward', '40')

while True:
if n.get_value('in1') > 20 and n.get_value('in2') > 20:
n.servo_rotate_by_degree('out1', 'forward', '50', '20')
Expand Down

0 comments on commit 3cd59c1

Please sign in to comment.