
import serial
import sonic


sonic_pi = sonic.SonicPi()
connection = serial.Serial('/dev/tty.usbmodem1421', 115200)

while True:
    line = connection.readline()
    command, argument = line.strip().split(' ', 1)
    if command == 'pad':
        number = int(argument)
        sonic_pi.run('cue :pad, number: {}'.format(number))



import serial
import sonic
import glob


sonic_pi = sonic.SonicPi()
connection = serial.Serial(glob.glob('/dev/tty.usbmodem*')[0], 115200)

while True:
    line = connection.readline()
    command, argument = line.strip().split(' ', 1)
    if command == 'pad':
        number = int(argument)
        sonic_pi.run('cue :pad, number: {}'.format(number))


Use `glob` to find an appropriate serial ttry
Use `glob` to find an appropriate serial ttry
  
  import serial
  import sonic
+ import glob
  
  
  sonic_pi = sonic.SonicPi()
- connection = serial.Serial('/dev/tty.usbmodem1421', 115200)
+ connection = serial.Serial(glob.glob('/dev/tty.usbmodem*')[0], 115200)
  
  while True:
      line = connection.readline()
      command, argument = line.strip().split(' ', 1)
      if command == 'pad':
          number = int(argument)
          sonic_pi.run('cue :pad, number: {}'.format(number))
  
  
Use `glob` to find an appropriate serial ttry
## Code Before:

import serial
import sonic


sonic_pi = sonic.SonicPi()
connection = serial.Serial('/dev/tty.usbmodem1421', 115200)

while True:
    line = connection.readline()
    command, argument = line.strip().split(' ', 1)
    if command == 'pad':
        number = int(argument)
        sonic_pi.run('cue :pad, number: {}'.format(number))


## Instruction:
Use `glob` to find an appropriate serial ttry
## Code After:

import serial
import sonic
import glob


sonic_pi = sonic.SonicPi()
connection = serial.Serial(glob.glob('/dev/tty.usbmodem*')[0], 115200)

while True:
    line = connection.readline()
    command, argument = line.strip().split(' ', 1)
    if command == 'pad':
        number = int(argument)
        sonic_pi.run('cue :pad, number: {}'.format(number))

