Skip to content

Instantly share code, notes, and snippets.

@Ryomasao
Created August 31, 2017 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryomasao/f847689a561f887d5169224066e0dc38 to your computer and use it in GitHub Desktop.
Save Ryomasao/f847689a561f887d5169224066e0dc38 to your computer and use it in GitHub Desktop.
レゴカーコントローラーの抜粋(コントローラー)
# -*- coding: utf-8 -*-
import wiringpi as pi
import sys
class LegoCarController:
'''
レゴカーを動かすためのクラス
前進と後退するためのDCモーター、ステアリング処理を行うサーボモータを制御している。
制御するためのGPIOは、初期処理で固定で決めている。
'''
def __init__(self):
pi.wiringPiSetupGpio()
#サーボモータを制御するクラス
self.servo_motor = NewServoMotor(18)
def handle(self, order):
'''
orderの値をもとに、まがる。
:param order:
:return:
'''
if order == b'd' :
#右
self.servo_motor.plusRotation()
elif order == b'a':
#左
self.servo_motor.minusRotation()
else:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment