Esempio n. 1
0
    'rawlings': '4093246',
    'reitz': '4093250'
}

url = 'https://transloc-api-1-2.p.mashape.com/arrival-estimates.json?agencies=116&callback=call'
hds1 = {
    "X-Mashape-Key": "ayK260XAjgmshBGGBApDm4RaUEjSp1W7ktdjsngDEsOgWwRl5v",
    "Accept": "application/json"
}
stop_flag = False

client = TwilioRestClient('AC967eb24d951cf34dc1d2337be54a052a',
                          '4e16db7df5b4c6661098bb0620922477')

port = 'COM4'
board = CircuitPlayground(port)
board.set_pixel_brightness(50)
scale = [
    262, 294, 330, 349, 392, 440, 494, 440, 392, 349, 330, 294, 262, 262, 294,
    330, 349, 392, 440, 494, 440, 392, 349, 330, 294, 262, 262, 294, 330, 349,
    392, 440, 494, 440, 392, 349, 330, 294, 262, 262, 294, 330, 349, 392, 440,
    494, 440, 392, 349, 330, 294, 262
]
duration = 250


def right_changed(data):
    global stop_flag
    print('Right button changed!')
    stop_flag = True
    return
Esempio n. 2
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define a C major scale of frequencies (C4, D4, E4, F4, G4, A4, B4) up & down.
# Tone frequency values from:
#   https://www.arduino.cc/en/Tutorial/ToneMelody?from=Tutorial.Tone
scale = [262, 294, 330, 349, 392, 440, 494, 440, 392, 349, 330, 294, 262]

# Set the duration of each note (in milliseconds)
duration = 500

# Loop through the scale and play each note.
print('Playing scale...')
for note in scale:
    # Play the note using the tone function.
    board.tone(note, duration)
    # Wait for the tone to finish playing, and add a small delay between notes
import atexit
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Initialize reading the thermistor by calling start_temperature once.
board.start_temperature()

# Optionally you can pass a callback function that will be called when a new
# temperature measurement is available.  This function should take two
# parameters, the temp in celsius and the raw ADC value.  See the commented
# code below:
# def new_temp(temp_c, raw):
#     print('Temperature: {0:.2f} Celsius'.format(temp_c))
#     print('Raw thermistor ADC value: {0}'.format(raw))
# board.start_temperature(new_temp)

# Loop forever printing the temperature every second.
print('Printing temperature (Ctrl-C to quit)...')
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define functions that will be called when the buttons change state.
def left_changed(data):
    # Check if left button digital input is high, i.e. button is pressed.
    # Note that data[2] contains the current digital input state.
    if data[2]:
        print('Left button pressed!')
    else:
        print('Left button released!')

def right_changed(data):
    # Check if right button digital input is high, i.e. button is pressed.
    # Note that data[2] contains the current digital input state.
    if data[2]:
        print('Right button pressed!')
Esempio n. 5
0
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
#if len(sys.argv) != 2:
#    print('ERROR! Must specify the serial port as command line parameter.')
#    sys.exit(-1)
#port = sys.argv[1]
port  = "/dev/tty.usbmodem1411"

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Callback that will be called when a tap is detected.  The single parameter is
# a boolean that indicates if it was a single tap, and the double parameter is
# a boolean that indicates if it was a double tap.  You might see both a single
# and double tap!
def tap_data(single, double):
    if single:
        print('Single click!')
    if double:
        print('Double click!')

# Grab a tap detection reading every 2 seconds.
print('Printing tap detection every 2 seconds (Ctrl-C to quit)...')
while True:
    board.read_tap(tap_data)
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define a rainbow of colors:
colors = [ (255,   0,   0),  # Red color (components are red, green, blue)
           (255, 128,   0),  # Orange
           (255, 255,   0),  # Yellow
           (  0, 255,   0),  # Green
           (  0,   0, 255),  # Blue
           ( 75,   0, 130),  # Indigo
           (143,   0, 255) ] # Violet

# Adjust the brightness of all the pixels by calling set_pixel_brightness.
# Send a value from 0 - 100 which means dark to full bright.
# Note that if you go down to 0 brightness you won't be able to go back up
# to higher brightness because the color information is 'lost'.  It's best to
# just call set brightness once at the start to set a good max brightness instead
Esempio n. 7
0
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
#if len(sys.argv) != 2:
#    print('ERROR! Must specify the serial port as command line parameter.')
#    sys.exit(-1)
#port = sys.argv[1]

port = "/dev/tty.usbmodem1411"

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)


def accel_data(x, y, z):
    print('Received accelerometer data!')
    print('X = {0}'.format(x))
    print('Y = {0}'.format(y))
    print('Z = {0}'.format(z))


# Grab an accelerometer reading every 2 seconds.
print('Printing accelerometer data (Ctrl-C to quit)...')
while True:
    board.read_accel(accel_data)
    time.sleep(2.0)
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Callback that will be called when a cap touch input result is available.
# The input_pin parameter is the pin number of the input, the touched parameter
# is a boolean that's true if the cap touch input is above a touch threshold
# (as defined by circuitplayground.CAP_THRSHOLD), and raw_value is the raw
# cap touch library value for the input (the bigger the value the more
# capacitance/bigger the thing touching an input).
def cap_touch_data(input_pin, touched, raw_value):
    print('Cap touch value for pin {0}: {1}'.format(input_pin, raw_value))
    if touched:
        print('Cap touch pin {0} is pressed!'.format(input_pin))

# Grab cap touch input 10's state every 2 seconds.
# You can read any of these inputs: 0, 1, 2, 3, 6, 9, 10, 12
print('Printing cap touch input 10 state (Ctrl-C to quit)...')
def right_changed(data):
    global current_frequency
    if not data[2]:
        # Move to the next frequency when button is released.
        current_frequency = (current_frequency + 1) % len(FREQUENCIES)


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Adjust the brightness of all the pixels by calling set_pixel_brightness.
# Send a value from 0 - 100 which means dark to full bright.
# Note that if you go down to 0 brightness you won't be able to go back up
# to higher brightness because the color information is 'lost'.  It's best to
# just call set brightness once at the start to set a good max brightness instead
# of trying to make animations with it.
board.set_pixel_brightness(50)

# Setup Firmata to listen to button changes.
# The buttons/switches on Circuit Playground use these pins:
#  - Left button = Digital pin 4
#  - Right button = Digital pin 19
board.set_pin_mode(4, board.INPUT, board.DIGITAL, left_changed)
board.set_pin_mode(19, board.INPUT, board.DIGITAL, right_changed)
Esempio n. 10
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)


# Define functions that will be called when the buttons change state.
def left_changed(data):
    # Check if left button digital input is high, i.e. button is pressed.
    # Note that data[2] contains the current digital input state.
    if data[2]:
        print('Left button pressed!')
    else:
        print('Left button released!')


def right_changed(data):
    # Check if right button digital input is high, i.e. button is pressed.
    # Note that data[2] contains the current digital input state.
    if data[2]:
# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Define a function which will be called when a color is detect and received.
# The red green blue parameters will be set with values from 0 to 255 (inclusive)
# which repreent the red, green, blue color value (0 is minimum intentiy, 255
# is maximum intensity).
def color(red, green, blue):
    print('Detected red={0} green={1} blue={2}'.format(red, green, blue))

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Loop forever reading the color every second and printing it out.
try:
    print('Reading color every second, press Ctrl-C to quit...')
    while True:
        # Call sense_color and provide the color callback function defined above.
        board.sense_color(color)
        time.sleep(1)
finally:
    # Close Firmata board connection when done.
    board.close()
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

def accel_data(x, y, z):
    print('Received accelerometer data!')
    print('X = {0}'.format(x))
    print('Y = {0}'.format(y))
    print('Z = {0}'.format(z))

# Grab an accelerometer reading every 2 seconds.
print('Printing accelerometer data (Ctrl-C to quit)...')
while True:
    board.read_accel(accel_data)
    time.sleep(2.0)

# Close Firmata board connection when done.
board.close()
Esempio n. 13
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Callback that will be called when a tap is detected.  The single parameter is
# a boolean that indicates if it was a single tap, and the double parameter is
# a boolean that indicates if it was a double tap.  You might see both a single
# and double tap!
def tap_data(single, double):
    if single:
        print('Single click!')
    if double:
        print('Double click!')

# Grab a tap detection reading every 2 seconds.
print('Printing tap detection every 2 seconds (Ctrl-C to quit)...')
while True:
    board.read_tap(tap_data)
Esempio n. 14
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define a rainbow of colors:
colors = [
    (255, 0, 0),  # Red color (components are red, green, blue)
    (255, 128, 0),  # Orange
    (255, 255, 0),  # Yellow
    (0, 255, 0),  # Green
    (0, 0, 255),  # Blue
    (75, 0, 130),  # Indigo
    (143, 0, 255)
]  # Violet

# Adjust the brightness of all the pixels by calling set_pixel_brightness.
# Send a value from 0 - 100 which means dark to full bright.
# Note that if you go down to 0 brightness you won't be able to go back up
# to higher brightness because the color information is 'lost'.  It's best to
Esempio n. 15
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
#if len(sys.argv) != 2:
#    print('ERROR! Must specify the serial port as command line parameter.')
#    sys.exit(-1)
#port = sys.argv[1]
port = "/dev/tty.usbmodem1411"

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)


# Callback that will be called when a cap touch input result is available.
# The input_pin parameter is the pin number of the input, the touched parameter
# is a boolean that's true if the cap touch input is above a touch threshold
# (as defined by circuitplayground.CAP_THRSHOLD), and raw_value is the raw
# cap touch library value for the input (the bigger the value the more
# capacitance/bigger the thing touching an input).
def cap_touch_data(input_pin, touched, raw_value):
    print('Cap touch value for pin {0}: {1}'.format(input_pin, raw_value))
    if touched:
        print('Cap touch pin {0} is pressed!'.format(input_pin))


# Grab cap touch input 10's state every 2 seconds.
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# You can optionally set the sensitivity of tap detection by calling
# the set_tap_config function.  This takes in two parameters:
# - Tap type:
#    0 = no tap detection
#    1 = single tap detection
#    2 = single & double tap detection (default)
# - Tap threshold, a value of 0-255 where the higher the value the less sensitive
#   the tap detection.  This value depends on the accelerometer range (see the
#   set_accel_range function in the accelerometer_streaming.py example) and good
#   values for each range are:
#     - Accel range +/-16G = 5-10
#     - Accel range +/-8G  = 10-20
#     - Accel range +/-4G  = 20-40
#     - Accel range +/-2G  = 40-80 (80 is the default)
Esempio n. 17
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define function that will be called when data is received from the light sensor.
def light_data(data):
    # Print out the raw light sensor ADC value (data[2] holds the value).
    print('Light sensor: {0}'.format(data[2]))

# Setup Firmata to listen to light sensor analog input (A5).
# The callback function will be called whenever new data is available.
board.set_pin_mode(5, board.INPUT, board.ANALOG, light_data)

# Loop forever printing light values as they change.
print('Printing light sensor values (Ctrl-C to quit)...')
while (True):
    time.sleep(1)  # Do nothing and just sleep.  When data is available the callback
                   # functions above will be called.
Esempio n. 18
0
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
# if len(sys.argv) != 2:
#     print('ERROR! Must specify the serial port as command line parameter.')
#     sys.exit(-1)
# port = sys.argv[1]
port = '/dev/cu.usbmodem1602551'
nframes = 100

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define a rainbow of colors:
colors = [
    (255, 0, 0),  # Red color (components are red, green, blue)
    (255, 128, 0),  # Orange
    (255, 255, 0),  # Yellow
    (0, 255, 0),  # Green
    (0, 0, 255),  # Blue
    (75, 0, 130),  # Indigo
    (143, 0, 255)
]  # Violet

# Adjust the brightness of all the pixels by calling set_pixel_brightness.
# Send a value from 0 - 100 which means dark to full bright.
# Note that if you go down to 0 brightness you won't be able to go back up
Esempio n. 19
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]


# Define a function which will be called when the version is received.
def print_version(maj, min, fix):
    print('Detected major={0} minor={1} fix={2}'.format(maj, min, fix))


# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

print('Reading version:')
board.read_implementation_version(print_version)
time.sleep(1)
# Close Firmata board connection when done.
board.close()
Esempio n. 20
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define a C major scale of frequencies (C4, D4, E4, F4, G4, A4, B4) up & down.
# Tone frequency values from:
#   https://www.arduino.cc/en/Tutorial/ToneMelody?from=Tutorial.Tone
scale = [262, 294, 330, 349, 392, 440, 494, 440, 392, 349, 330, 294, 262]

# Set the duration of each note (in milliseconds)
duration = 500

# Loop through the scale and play each note.
print('Playing scale...')
for note in scale:
    # Play the note using the tone function.
    board.tone(note, duration)
    # Wait for the tone to finish playing, and add a small delay between notes
    # (100 ms).
Esempio n. 21
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define function that will be called when data is received from the microphone.
def sound_data(data):
    # Print out the raw microphone ADC value (data[2] holds the value).
    print('Microphone: {0}'.format(data[2]))

# Setup Firmata to listen to the microphone analog input (A4):
# The callback functions will be called whenever new data is available.
board.set_pin_mode(4, board.INPUT, board.ANALOG, sound_data)

# Loop forever printing sound values as they change.
print('Printing microphone values (Ctrl-C to quit)...')
while (True):
    time.sleep(1)  # Do nothing and just sleep.  When data is available the callback
                   # functions above will be called.
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# You can optionally set the sensitivity of tap detection by calling
# the set_tap_config function.  This takes in two parameters:
# - Tap type:
#    0 = no tap detection
#    1 = single tap detection
#    2 = single & double tap detection (default)
# - Tap threshold, a value of 0-255 where the higher the value the less sensitive
#   the tap detection.  This value depends on the accelerometer range (see the
#   set_accel_range function in the accelerometer_streaming.py example) and good
#   values for each range are:
#     - Accel range +/-16G = 5-10
#     - Accel range +/-8G  = 10-20
#     - Accel range +/-4G  = 20-40
#     - Accel range +/-2G  = 40-80 (80 is the default)
board.set_tap_config(2, 80)
Esempio n. 23
0
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
#if len(sys.argv) != 2:
#    print('ERROR! Must specify the serial port as command line parameter.')
#    sys.exit(-1)
#port = sys.argv[1]
port  = "/dev/tty.usbmodem1411"

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Initialize reading the thermistor by calling start_temperature once.
board.start_temperature()

# Optionally you can pass a callback function that will be called when a new
# temperature measurement is available.  This function should take two
# parameters, the temp in celsius and the raw ADC value.  See the commented
# code below:
# def new_temp(temp_c, raw):
#     print('Temperature: {0:.2f} Celsius'.format(temp_c))
#     print('Raw thermistor ADC value: {0}'.format(raw))
# board.start_temperature(new_temp)

# Loop forever printing the temperature every second.
print('Printing temperature (Ctrl-C to quit)...')
Esempio n. 24
0
#!/usr/bin/python
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground

# Grab the serial port from the command line parameters.
if len(sys.argv) != 2:
    print('ERROR! Must specify the serial port as command line parameter.')
    sys.exit(-1)
port = sys.argv[1]

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)


# Define function that will be called when data is received from the light sensor.
def light_data(data):
    # Print out the raw light sensor ADC value (data[2] holds the value).
    print('Light sensor: {0}'.format(data[2]))


# Setup Firmata to listen to light sensor analog input (A5).
# The callback function will be called whenever new data is available.
board.set_pin_mode(5, board.INPUT, board.ANALOG, light_data)

# Loop forever printing light values as they change.
print('Printing light sensor values (Ctrl-C to quit)...')
while (True):
    time.sleep(
Esempio n. 25
0
import time
import sys

# Import CircuitPlayground class from the circuitplayground.py in the same directory.
from circuitplayground import CircuitPlayground


# Grab the serial port from the command line parameters.
#if len(sys.argv) != 2:
#    print('ERROR! Must specify the serial port as command line parameter.')
#    sys.exit(-1)
#port = sys.argv[1]
port  = "/dev/tty.usbmodem1411"

# Connect to Circuit Playground board on specified port.
board = CircuitPlayground(port)

# Define function that will be called when data is received from the microphone.
def sound_data(data):
    # Print out the raw microphone ADC value (data[2] holds the value).
    print('Microphone: {0}'.format(data[2]))

# Setup Firmata to listen to the microphone analog input (A4):
# The callback functions will be called whenever new data is available.
board.set_pin_mode(4, board.INPUT, board.ANALOG, sound_data)

# Loop forever printing sound values as they change.
print('Printing microphone values (Ctrl-C to quit)...')
while (True):
    time.sleep(1)  # Do nothing and just sleep.  When data is available the callback
                   # functions above will be called.