Beispiel #1
0
def init_gpio() :
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)

        #buttons
        GPIO.setup(red_btn, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(yellow_btn, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(green_btn, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        GPIO.setup(blue_btn, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

        #leds
        GPIO.setup(red_led, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(yellow_led, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(green_led, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(blue_led, GPIO.OUT, initial=GPIO.LOW)

        # add events
        GPIO.add_event_detect(red_btn, GPIO.RISING, callback=red_button_callback)
        GPIO.add_event_detect(yellow_btn, GPIO.RISING, callback=yellow_button_callback)
        GPIO.add_event_detect(green_btn, GPIO.RISING, callback=green_button_callback)
        GPIO.add_event_detect(blue_btn, GPIO.RISING, callback=blue_button_callback)

        #init speaker
        wiringpi.wiringPiSetupGpio()
        wiringpi.softToneCreate(speaker)
    def setup(self):
        # super() sets up all the laser stuff plus self.headFixTime plus # rewards(not used here)
        super().setup()
        self.summary_file_name = self.settingsDict.get(
            'summary_file_name', AHF_Stimulator_ClosedLoop.defaultSummaryFile)
        self.audio_pin = int(
            self.settingsDict.get('audio_pin',
                                  AHF_Stimulator_ClosedLoop.defaultAudioPin))
        self.num_tones = int(
            self.settingsDict.get('num_tones',
                                  AHF_Stimulator_ClosedLoop.defaultNumTones))
        self.moghistory = AHF_Stimulator_ClosedLoop.defaultMOGHistory
        self.var_threshold = AHF_Stimulator_ClosedLoop.defaultVarThreshold

        # Closed-loop specific settings
        # Starting audio pin
        wpi.wiringPiSetupGpio()
        wpi.softToneCreate(self.audio_pin)
        # Compute frequency
        self.freq_dict = self._get_freqs(self.num_tones)

        # General AHF attributes
        self.rewarder = self.task.Rewarder
        self.camera = self.task.Camera
        self.task.DataLogger.startTracking("Outcome", "code", "buffer", 200)
Beispiel #3
0
def set():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    wiringpi.wiringPiSetupGpio()
    wiringpi.softToneCreate(soundPIN)
    for pin in ledPIN:
        GPIO.setup(pin, GPIO.OUT, initial=GPIO.LOW)
    for pin in btnPIN:
        GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
Beispiel #4
0
def initialize_matrix():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    
    # setup default values for lights
    GPIO.setup(lights_arr, GPIO.OUT, initial=GPIO.LOW)
    
    # initialize siren
    wiringpi.wiringPiSetupGpio()
    wiringpi.softToneCreate(siren)
Beispiel #5
0
def main():
    args = parse_arguments()
    input_files = get_possible_midi_files(args["input_files"],
                                          args["is_silent"])
    random.shuffle(input_files)
    input_files = input_files[0:args["count"]]
    pins = [int(i) for i in args["pins"].split(",")]
    wiringpi.wiringPiSetupGpio()
    [wiringpi.softToneCreate(i) for i in pins]
    for i in input_files:
        stats = {
            "sustained_notes": 0,
            "length": 0,
            "note_count": 0,
            "bad_offs_count": 0
        }
        data = import_midi_file(i, args["is_silent"])
        data.sort(key=lambda x: int(x[1]))
        data, stats["sustained_notes"] = pedal_to_noteoff(
            data, args["use_pedal"])
        data, stats["length"], stats["note_count"] = convert_time(
            data, args["speed"])
        data, stats["bad_offs_count"] = restrict_number_of_notes(
            data, pins, args["shiftpitch"])
        if not args["is_silent"]:
            show_stats(stats)
        play(data)
def setup_gpio():
    wiringpi.wiringPiSetupGpio()  # setup wiring pi to use BCM pin numbers
    success = wiringpi.softToneCreate(PIN)  # Attempt to set up pin 18

    if success != 0:  # If an error is encountered setting up the pin...
        print >> sys.stderr, "Error setting up pin %d (Error Code: %d)." % PIN
        exit(1)
Beispiel #7
0
def make_sound(color, pin):
    wiringpi.softToneCreate(sound_gpiopin)
    freq = 0
    if color == 4:
        freq = 659
    elif color == 17:
        freq = 440
    elif color == 27:
        freq = 784
    elif color == 22:
        freq = 523
    elif color == 0:
        freq = 900
    wiringpi.softToneWrite(pin, freq)
    time.sleep(0.5)
    wiringpi.softToneStop(sound_gpiopin)
Beispiel #8
0
def initialize_matrix():

    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)

    # setup default values for button and lights
    GPIO.setup(buttons_arr, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.setup(lights_arr, GPIO.OUT, initial=GPIO.LOW)

    # set listener for button clicks
    GPIO.add_event_detect(red_btn, GPIO.FALLING, callback=check_playerz_move)
    GPIO.add_event_detect(yellow_btn,
                          GPIO.FALLING,
                          callback=check_playerz_move)
    GPIO.add_event_detect(green_btn, GPIO.FALLING, callback=check_playerz_move)
    GPIO.add_event_detect(blue_btn, GPIO.FALLING, callback=check_playerz_move)

    # initialize siren
    wiringpi.wiringPiSetupGpio()
    wiringpi.softToneCreate(siren)
Beispiel #9
0
def set():
    global gyro_data
    global sensor
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)

    # Acc setup
    sensor = mpu6050(0x68)
    gyro_data = sensor.get_gyro_data()
    gyro_data_perm = abs(gyro_data.get('y'))

    # Flame sensor setup
    GPIO.setup(yellowFlameSense, GPIO.IN)

    # Sound setup
    wiringpi.wiringPiSetupGpio()
    wiringpi.softToneCreate(soundPIN)

    # Led setup
    for pin in ledPIN:
        GPIO.setup(pin, GPIO.OUT, initial=GPIO.LOW)

    # Button setup
    for pin in btnPIN:
        GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

    # Add event detections
    GPIO.add_event_detect(redBTN,
                          GPIO.RISING,
                          bouncetime=300,
                          callback=red_pushed)
    GPIO.add_event_detect(blueBTN,
                          GPIO.RISING,
                          bouncetime=300,
                          callback=blue_pushed)
    GPIO.add_event_detect(yellowFlameSense,
                          GPIO.BOTH,
                          bouncetime=300,
                          callback=yellow_pushed)
Beispiel #10
0
 def __init__(self, gpio=2, frequency=100):
     wiringpi.wiringPiSetup()
     self.frequency = frequency
     self.gpio = gpio
     wiringpi.softToneCreate(self.gpio)
     wiringpi.softToneWrite(self.gpio, self.frequency)
Beispiel #11
0
import wiringpi
from time import sleep
pin = 18

wiringpi.wiringPiSetupGpio()

try:
    wiringpi.softToneCreate(pin)
    while True:
        wiringpi.softToneWrite(pin, 392)
        sleep(0.5)
        wiringpi.softToneWrite(pin, 523)
        sleep(0.5)
finally:
    wiringpi.pinMode(pin, 0)
Beispiel #12
0
def tone(pin, freq):
    wiringpi.softToneCreate(pin)
    wiringpi.softToneWrite(pin, freq)
Beispiel #13
0
def bip(f,l):
    wiringpi.softToneWrite(buzzerPIN,f)
    time.sleep(l/1000.0)
    wiringpi.softToneWrite(buzzerPIN,0)

def setled(r,g,b):
    wiringpi.digitalWrite(ledR,r)
    wiringpi.digitalWrite(ledG,g)
    wiringpi.digitalWrite(ledB,b)

def getled():
    return ( wiringpi.digitalRead(ledR), wiringpi.digitalRead(ledG), wiringpi.digitalRead(ledB) )

wiringpi.wiringPiSetupGpio()

wiringpi.softToneCreate(buzzerPIN)

wiringpi.pinMode(buttonLED, 1)
wiringpi.digitalWrite(buttonLED, 1)
for led in [ledR,ledG,ledB]:
    wiringpi.pinMode(led, 1)

setled(1,0,0)


# Set all address lines high
for addressLine in addressLines:
    wiringpi.pinMode(addressLine, 1)
    wiringpi.digitalWrite(addressLine, 1)

# Set all data lines for input
Beispiel #14
0
def main():
    """
    本体
    """
    """
    PIN NOの定義
    """
    buz = 21
    """
    GPIOの初期設定
    """
    pi.wiringPiSetupGpio()
    pi.softToneCreate(buz)
    """
    モールス符号用辞書
    """
    # キーは文字で値は長さ
    # 英数ひらがなに対応
    # 拗音 促音は通常の文字とする
    dic = {
        '0': [3, 3, 3, 3, 3],
        '1': [1, 3, 3, 3, 3],
        '2': [1, 1, 3, 3, 3],
        '3': [1, 1, 1, 3, 3],
        '4': [1, 1, 1, 1, 3],
        '5': [1, 1, 1, 1, 1],
        '6': [3, 1, 1, 1, 1],
        '7': [3, 3, 1, 1, 1],
        '8': [3, 3, 3, 1, 1],
        '9': [3, 3, 3, 3, 1],
        'a': [1, 3],
        'b': [3, 1, 1, 1],
        'c': [3, 1, 3, 1],
        'd': [3, 1, 1],
        'e': [1],
        'f': [1, 1, 3, 1],
        'g': [3, 3, 1],
        'h': [
            1,
            1,
            1,
            1,
        ],
        'i': [1, 1],
        'j': [1, 3, 3, 3],
        'k': [3, 1, 3],
        'l': [1, 3, 1, 1],
        'm': [3, 3],
        'n': [3, 1],
        'o': [3, 3, 3],
        'p': [1, 3, 3, 1],
        'q': [3, 3, 1, 3],
        'r': [1, 3, 1],
        's': [1, 1, 1],
        't': [3],
        'u': [1, 1, 3],
        'v': [1, 1, 1, 3],
        'w': [1, 3, 3],
        'x': [3, 1, 1, 3],
        'y': [3, 1, 3, 3],
        'z': [3, 3, 1, 1],
        'あ': [3, 3, 1, 3, 3],
        'い': [1, 3],
        'う': [1, 1, 3],
        'え': [3, 1, 3, 3, 3],
        'お': [1, 3, 1, 1, 1],
        'か': [1, 3, 1, 1],
        'き': [3, 1, 3, 1, 1],
        'く': [1, 1, 1, 3],
        'け': [3, 1, 3, 3],
        'こ': [3, 3, 3, 3],
        'さ': [3, 1, 3, 1, 3],
        'し': [3, 3, 1, 3, 1],
        'す': [3, 3, 3, 1, 3],
        'せ': [1, 3, 3, 3, 1],
        'そ': [3, 3, 3, 1],
        'た': [3, 1],
        'ち': [1, 1, 3, 1],
        'つ': [1, 3, 3, 1],
        'て': [1, 3, 1, 3, 3],
        'と': [1, 1, 3, 1, 1],
        'な': [1, 3, 1],
        'に': [3, 1, 3, 1],
        'ぬ': [1, 1, 1, 1],
        'ね': [
            3,
            3,
            1,
            3,
        ],
        'の': [1, 1, 3, 3],
        'は': [3, 1, 1, 1],
        'ひ': [3, 3, 1, 1, 3],
        'ふ': [3, 3, 1, 1],
        'へ': [1],
        'ほ': [3, 1, 1],
        'ま': [3, 1, 1, 3],
        'み': [1, 1, 3, 1, 3],
        'む': [3],
        'め': [3, 1, 1, 1, 3],
        'も': [3, 1, 1, 3, 1],
        'や': [1, 3, 3],
        'ゆ': [3, 1, 1, 3, 3],
        'よ': [3, 3],
        'ら': [1, 1, 1],
        'り': [3, 3, 1],
        'る': [3, 1, 3, 3, 1],
        'れ': [3, 3, 3],
        'ろ': [1, 3, 1, 3],
        'わ': [3, 1, 3],
        'を': [1, 3, 3, 3],
        'ん': [1, 3, 1, 3, 1],
        'が': [1, 3, 1, 1, 1, 1],
        'ぎ': [3, 1, 3, 1, 1, 1, 1],
        'ぐ': [1, 1, 1, 3, 1, 1],
        'げ': [3, 1, 3, 3, 1, 1],
        'ご': [3, 3, 3, 3, 1, 1],
        'ざ': [3, 1, 3, 1, 3, 1, 1],
        'じ': [3, 3, 1, 3, 1, 1, 1],
        'ず': [3, 3, 3, 1, 3, 1, 1],
        'ぜ': [1, 3, 3, 3, 1, 1, 1],
        'ぞ': [3, 3, 3, 1, 1, 1],
        'だ': [3, 1, 1, 1],
        'ぢ': [1, 1, 3, 1, 1, 1],
        'づ': [1, 3, 3, 1, 1, 1],
        'で': [1, 3, 1, 3, 3, 1, 1],
        'ど': [1, 1, 3, 1, 1, 1, 1],
        'ば': [3, 1, 1, 1, 1, 1],
        'び': [3, 3, 1, 1, 3, 1, 1],
        'ぶ': [3, 3, 1, 1, 1, 1],
        'べ': [1, 1, 1],
        'ぼ': [3, 1, 1, 1, 1],
        'ぱ': [3, 1, 1, 1, 1, 1, 3, 3, 1],
        'ぴ': [3, 3, 1, 1, 3, 1, 1, 3, 3, 1],
        'ぷ': [3, 3, 1, 1, 1, 1, 3, 3, 1],
        'ぺ': [1, 1, 3, 3, 1],
        'ぽ': [3, 1, 1, 1, 1, 3, 3, 1],
        'ー': [1, 3, 3, 1, 3]
    }
    """
    実行部
    """

    # 拗音 促音を変換するためのlistの用意
    pal_word = ["っ", "ゃ", "ゅ", "ょ", "ぁ", "ぃ", "ぅ", "ぇ", "ぉ"]
    con_word = ["つ", "や", "ゆ", "よ", "あ", "い", "う", "え", "お"]

    while True:
        """
        入力チェックと置き換え
        """
        # 英字の大文字は小文字に変換
        inp_w = input('発信したい文字を' '半角英数、ひらがなで入れて' 'ください >> ').lower()
        # print("入力された文字は 【{}】".format(inp_w))

        # 入力された文字の拗音 促音を置き換え
        # 一文字毎リスト化
        for p, c in zip(pal_word, con_word):
            # print(p, c)
            inp_w = [l.replace(p, c) for l in inp_w]
            # print(inp_w)
        # print("置き換え後の文字リスト 【{}】".format(inp_w))

        # 文字のチェック
        for w in inp_w:
            if "あ" <= w <= "ん" \
                    or "a" <= w <= "z" \
                    or "1" <= w <= "9" \
                    or w == "ー" \
                    or w == " ":
                pass

            else:
                print("半角英数、ひらがな以外が入っています")
                break
        else:
            print("入力チェックOK")
            break
    """
    制御
    """
    for word in inp_w:
        # 辞書のキーを指定して音を鳴らす
        # 長音は単音の3倍
        for long in dic[word]:
            print("発音してる文字 【{}】".format(word))
            print("発音の長さ 【{}】".format(long))
            pi.softToneWrite(buz, 1000)
            sleep(long / 15)
            pi.softToneWrite(buz, 0)
            # 符号間の間は短音と同じ間隔
            sleep(1 / 15)
        # 文字間は長音と同じ
        sleep(3 / 15)
Beispiel #15
0
# Test of the softTone module in wiringPi
# Plays a scale out on pin 3 - connect pizeo disc to pin 3 & 0v
import wiringpi

PIN = 3

SCALE = [262, 294, 330, 349, 392, 440, 494, 525]

wiringpi.wiringPiSetup()
wiringpi.softToneCreate(PIN)

while True:
    for idx in range(8):
        print(idx)
        wiringpi.softToneWrite(PIN, SCALE[idx])
        wiringpi.delay(500)
Beispiel #16
0
import wiringpi
import time

#General Setup
wiringpi.wiringPiSetupGpio()

wiringpi.softToneCreate(25)

# 200Hz frequency on GPIO25
wiringpi.softToneWrite(25, 200)

# Run for 0.7 seconds
time.sleep(0.7)

# Stop the tone
wiringpi.softToneStop(25)
Beispiel #17
0
gpioButtonYellow = 6
gpioButtonGreen = 13
gpioButtonBlue = 19
gpioSpeaker = 17

led = [gpioPinRed, gpioPinYellow, gpioPinGreen, gpioPinBlue]
buttons = [gpioButtonRed, gpioButtonYellow, gpioButtonGreen, gpioButtonBlue]
sounds = [440, 523, 659, 784]

moves = []
playing = True

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
wiringpi.wiringPiSetupGpio()
wiringpi.softToneCreate(gpioSpeaker)

for i in range(0, len(led)):
    GPIO.setup(buttons[i], GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.setup(led[i], GPIO.OUT, initial=GPIO.LOW)

while playing:
    currentMove = random.randint(0, 3)
    moves.append(currentMove)

    for move in range(0, len(moves)):
        wiringpi.softToneWrite(gpioSpeaker, sounds[moves[move]])
        GPIO.output(led[moves[move]], GPIO.HIGH)
        sleep(1)
        wiringpi.softToneWrite(gpioSpeaker, -sounds[moves[move]])
        GPIO.output(led[moves[move]], GPIO.LOW)
Beispiel #18
0
 def __init__(self, pin):
     """ 初期化メソッド """
     self.pin = pin  # 電子スピーカー用のGPIOピン
     wiringpi.softToneCreate(self.pin)
Beispiel #19
0
MISO = 23
MOSI = 24
CS = 25
mcp = Adafruit_MCP3008.MCP3008(clk = CLK, cs = CS, miso = MISO, mosi = MOSI)

#gyro sensor setup
gyroSensor = mpu6050(0x68)

#game output setup
gpioSound = 5
Led_Array = [12,17,27,22] #red, yellow, green, blue
mapping = {0:(12,440), 1:(17,523),2:(27,659),3:(22,784)}

#sound setup
wiringpi.wiringPiSetupGpio()
wiringpi.softToneCreate(gpioSound)

roundList = []
roundListIterator = 0

#Set all the Led pins to outputs
for index in range(len(Led_Array)):
	GPIO.setup(Led_Array[index], GPIO.OUT)

def checkUserInput(index):
	global roundList
	global roundListIterator

	if(index != roundList[roundListIterator]):
		roundList = []
		roundListIterator = 0
Beispiel #20
0
import RPi.GPIO as GPIO
import wiringpi

GPIO.setmode(GPIO.BCM)  #Setting the Mode to use. I am using the BCM setup
GPIO.setwarnings(False)

#Declaring the GPIO Pins that the motor controller is set with
m0Right = 8
m1Right = 7
m2Right = 20
sleepPinRight = 16
stepRight = 12
directionRight = 21
GPIO.setup(sleepPinRight, GPIO.OUT)
# GPIO.setup(stepRight, GPIO.OUT)
GPIO.setup(directionRight, GPIO.OUT)
GPIO.setup(m0Right, GPIO.OUT)
GPIO.setup(m1Right, GPIO.OUT)
GPIO.setup(m2Right, GPIO.OUT)
# PWM1 = GPIO.PWM(stepRight, 50)
# PWM1.start(0)

wiringpi.wiringPiSetup()
wiringpi.softToneCreate(stepRight)

try:
    while True:
        wiringpi.softToneWrite(stepRight, 100)

except KeyboardInterrupt:
    berhenti()
Beispiel #21
0
greenLight = 21
greenButton = 6

#Tone
redTone = 527
blueTone = 887
yellowTone = 745
greenTone = 469

greenTone = 469

##n dkjnfskjdsnfdskljndskj
#speaker GPIO
speaker = 5
wiringpi.wiringPiSetupGpio()
wiringpi.softToneCreate(speaker)

#initializations
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(redLight, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(redButton, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(blueLight, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(blueButton, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(yellowLight, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(yellowButton, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(greenLight, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(greenButton, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
Beispiel #22
0
 def __init__(self, num):
     super(Buzzer, self).__init__(num)
     self.__num = num
     wiringpi.softToneCreate(self.__num)
Beispiel #23
0
import wiringpi as pi

delay = 0.2
buzzer_pin = 25
led_pin = 23
sensor_pin = 18
count = 0

E = 265

GPIO.setmode(GPIO.BCM)
GPIO.setup(buzzer_pin, GPIO.OUT)

pi.wiringPiSetupGpio()  # GPIO名で番号を指定する

pi.softToneCreate(buzzer_pin)
pi.pinMode(led_pin, pi.OUTPUT)
pi.pinMode(sensor_pin, pi.INPUT)

while True:
    if (pi.digitalRead(sensor_pin) == pi.HIGH):
        while count < 5:
            pi.softToneWrite(buzzer_pin, E)
            pi.digitalWrite(led_pin, pi.HIGH)
            sleep(delay * 2)
            pi.softToneWrite(buzzer_pin, 0)
            pi.digitalWrite(led_pin, pi.LOW)
            sleep(delay)
            count += 1
        count = 0
    else:
Beispiel #24
0
    def setup(self, pin, mode):
        if mode == modes.PWM:
            wpi.softToneCreate(pin)

        return True
Beispiel #25
0
def init():
	wp.wiringPiSetupGpio()
	wp.softToneCreate(BUZZER_PIN)
	stopFreq()
Beispiel #26
0
 def __init__(self):
     wiringpi.wiringPiSetup()
     wiringpi.softToneCreate(self.PIN)
Beispiel #27
0
 def __init__(self):
     wiringpi.wiringPiSetupGpio()
     wiringpi.softToneCreate(self.SOUNDER)
     wiringpi.pinMode(self.SW1, 0)
Beispiel #28
0
import wiringpi  
from time import sleep  
PIN_BUZ = 18

frequencies = {'c':262, 'd':294, 'e':330, 'f':349, 'g':392, 'a':440, 'b':494}
notes = 'ccggaag ffeeddc ggffeed ggffeed ccggaag ffeeddc'

wiringpi.wiringPiSetupGpio()  
try:
    wiringpi.softToneCreate(PIN_BUZ)
    for i in notes:
        if i != ' ':
            wiringpi.softToneWrite(PIN_BUZ, frequencies[i])
        else:
            wiringpi.softToneWrite(PIN_BUZ, 0)
        sleep(0.3)
finally:
    wiringpi.pinMode(PIN_BUZ, 0)
C = 190
D = 240
E = 265
F = 315
G = 365
A = 390
B = 415

GPIO.setmode(GPIO.BCM)
GPIO.setup(led_r_pin, GPIO.OUT)
GPIO.setup(led_g_pin, GPIO.OUT)
GPIO.setup(led_b_pin, GPIO.OUT)
GPIO.setup(beep_pin, GPIO.OUT)

wiringpi.wiringPiSetupGpio()
wiringpi.softToneCreate(beep_pin)


def led(r, g, b):
    GPIO.output(led_r_pin, not r)
    GPIO.output(led_g_pin, not g)
    GPIO.output(led_b_pin, not b)


def post(id):
    url = "https://halake-users.herokuapp.com/api/v1/nfc_ids"
    params = urllib.urlencode({"nfc_id": id})
    req = urllib2.Request(url)
    req.add_header('Content-Type', 'application/x-www-form-urlencoded')
    req.add_data(params)
    res = urllib2.urlopen(req).read()