Last active
January 14, 2022 02:13
-
-
Save ryoko-saito/59d3e13b732de61d24c645064dacb923 to your computer and use it in GitHub Desktop.
This file contains 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 gpiozero import AngularServo | |
from guizero import App, Slider | |
#gpiozeroライブラリからServo とSliderのクラスをimportする | |
servo = AngularServo(18, min_pulse_width=0.5/1000, max_pulse_width=2.5/1000) | |
#画面の右下のスライダーのメモリをマウスで動かしたときにどういう処理にするかの設計図 | |
def slider_changed(angle): | |
servo.angle = int(angle) | |
#スライダーで得られた情報をサーボモーターに渡す | |
app = App(title='Servo Angle', width=500, height=150) | |
#右下に出るスライダーの幅と高さを指定する | |
slider = Slider(app, start=-90, end=90, command=slider_changed, width='fill', height=50) | |
#スライダーは高さが50pxで左が-90、右が90のバーが出ます。スライダーから値を受け取った時にslider_changedを実行する | |
slider.text_size = 30 | |
#スライダーに出る文字の大きさは30 | |
app.display() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment