본문 바로가기
공부,일/라즈베리 파이

라즈베리 파이 to 아두이노 실습(2)

by fromnothing1 2021. 8. 13.

 

#!/usr/bin/python
#-*- coding:utf-8 -*

import pyfirmata
print("아두이노 연결중")
ObjArduino = pyfirmata.Arduino('/dev/ttyACM0')
print("아두이노 연결완료 !")

ObjPwm     = ObjArduino.get_pin('d:3:p') # d(digital)/a(analog)
                                                                               # pin number
                                                                               # i(input)/0(output)/p(pwm)

try:
        while True:
                print("와일")
                duty = int(input("duty 비를 입력하시오 (최대 100):"))
                ObjPwm.write(duty/100.0) #duty 는 1을 넘을 수 없음

        pass
except:
        print("except")
        pass

ObjArduino.exit()

댓글