Last active
January 8, 2023 06:53
-
-
Save aliorhun/0c345d584048a7c49dbcf77341e9c220 to your computer and use it in GitHub Desktop.
Uzaktan kumanda kullanarak Pybrick için ilk deneme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pybricks.pupdevices import Motor | |
| from pybricks.parameters import Port | |
| from pybricks.tools import wait | |
| from pybricks.pupdevices import Remote | |
| from pybricks.parameters import Button, Color | |
| from pybricks.hubs import PrimeHub | |
| from pybricks.tools import wait | |
| from pybricks.parameters import Icon | |
| # Hub üzerindeki ışıkları kapatma | |
| hub = PrimeHub() | |
| hub.display.off() | |
| hub.light.off() | |
| # A girişindeki motoru tanımlama (motor01) | |
| motor01 = Motor(Port.A) | |
| # C girişindeki motoru tanımlama (motor02) | |
| motor02 = Motor(Port.C) | |
| # Kumandayı tanımlama | |
| remote = Remote() | |
| # işlemler | |
| while True: | |
| pressed = () | |
| # tıklanılmadığında | |
| while not pressed: | |
| pressed = remote.buttons.pressed() | |
| motor01.reset_angle(0) | |
| motor02.reset_angle(0) | |
| # Sağdaki tuşları motor01'e atama | |
| if Button.RIGHT_PLUS in pressed: | |
| motor01.run(45) | |
| if Button.RIGHT_MINUS in pressed: | |
| motor01.run(-45) | |
| # Soldaki tuşları motor02'ye atama | |
| if Button.LEFT_PLUS in pressed: | |
| motor02.run(45) | |
| if Button.LEFT_MINUS in pressed: | |
| motor02.run(-45) | |
| while pressed: | |
| pressed = remote.buttons.pressed() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment