Skip to content

Instantly share code, notes, and snippets.

@neosarchizo
Last active December 23, 2015 04:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save neosarchizo/4ace4b5ec9ee814afc3b to your computer and use it in GitHub Desktop.
[Raspberry Pi] 바보상자
import RPi.GPIO as GPIO
button = 4
servo = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(servo, GPIO.OUT)
pwm = GPIO.PWM(servo, 50)
pwm.start(4)
try:
while True:
if GPIO.input(button):
pwm.ChangeDutyCycle(12)
while GPIO.input(button): pass
pwm.ChangeDutyCycle(4)
finally:
pwm.stop()
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment