import time
from machine import Pin
from ETboard.lib.pin_define import *
from ETboard.lib.servo import Servo
# global variable
servo = Servo(Pin(D6)) # 서보모터 핀 지정
PUSH = Pin(D7) # 밀기 버튼 : 파랑 버튼 핀 지정
pos = 0
# setup
def setup():
PUSH.init(Pin.IN) # 밀기 버튼 입력모드 설정
# mainloop
def loop():
global pos
PUSH_state = PUSH.value()
if PUSH_state == LOW: #
pos = pos + 1
if (pos > 3):
pos = 0
servo.write_angle(180-(48*pos))
time.sleep(0.3)
if __name__ == "__main__":
setup()
while True:
loop()