Skip to content

Instantly share code, notes, and snippets.

@salexkidd
Created January 17, 2015 08:14
Show Gist options
  • Save salexkidd/6dec836b994aa04cff31 to your computer and use it in GitHub Desktop.
Save salexkidd/6dec836b994aa04cff31 to your computer and use it in GitHub Desktop.
LED_PERFUME
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import time
# 使うGPIOピンの番号
IO_NO = 15
IO_NO2 = 14
IO_NO3 = 18
sleep_time = 0.18
print("press ^C to exit program ...\n")
# GPIOピン番号を用いる
GPIO.setmode(GPIO.BCM)
# 基板上のピン番号を用いる
GPIO.setup(IO_NO, GPIO.OUT)
GPIO.setup(IO_NO2, GPIO.OUT)
GPIO.setup(IO_NO3, GPIO.OUT)
def play_kashiyuka(loop_count=0, sleep_time=0):
for i in range(loop_count):
GPIO.output(IO_NO, True)
time.sleep(sleep_time)
GPIO.output(IO_NO, False)
time.sleep(sleep_time)
def play_achan(loop_count=0, sleep_time=0):
for i in range(loop_count):
GPIO.output(IO_NO3, True)
time.sleep(sleep_time)
GPIO.output(IO_NO3, False)
time.sleep(sleep_time)
def play_nocchi(loop_count=0, sleep_time=0):
for i in range(loop_count):
GPIO.output(IO_NO2, True)
time.sleep(sleep_time)
GPIO.output(IO_NO2, False)
time.sleep(sleep_time)
def all_call():
for port in (IO_NO, IO_NO2, IO_NO3):
print IO_NO
GPIO.output(port, False)
for i in range(3):
for port in (IO_NO, IO_NO2, IO_NO3):
GPIO.output(port, True)
time.sleep(0.2)
for port in (IO_NO, IO_NO2, IO_NO3):
GPIO.output(port, False)
time.sleep(0.2)
call_sleep = 0.2
try:
while True:
#かしゆかです!
play_kashiyuka(loop_count=3, sleep_time=call_sleep)
time.sleep(0.5)
#あーちゃんです!
play_achan(loop_count=3, sleep_time=call_sleep)
time.sleep(0.5)
#のっちです!
play_nocchi(loop_count=2, sleep_time=call_sleep+0.2)
time.sleep(0.5)
#あーちゃん*4
play_achan(loop_count=4, sleep_time=call_sleep)
#パフュームです
time.sleep(0.1)
all_call()
time.sleep(3)
except KeyboardInterrupt:
print("detect key interrupt\n")
GPIO.cleanup()
print("Program exit\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment