#!/usr/bin/env python
import serial
import time


import sys
import signal

def signal_handler(signal, frame): # ctrl + c -> exit program
        print('You pressed Ctrl+C!')
        sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)



if __name__ == '__main__':
  ser = serial.Serial('/dev/ttyUSB0', 19200, timeout=1)  # open serial port
  print(ser.name)         # check which port was really used
  while 1:
      try:
        ser.write(b'hello')     # write a string
        print("sent \n")
        time.sleep(0.2)
      except (SystemExit, KeyboardInterrupt) :
        ser.close()             # close port
        sys.exit(0)

18c4e09da69558a2624dfa2fa72b16d420f9bb09
<mask token>

<mask token>


def signal_handler(signal, frame):
    print('You pressed Ctrl+C!')
    sys.exit(0)


<mask token>

<mask token>


def signal_handler(signal, frame):
    print('You pressed Ctrl+C!')
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
if __name__ == '__main__':
    ser = serial.Serial('/dev/ttyUSB0', 19200, timeout=1)
    print(ser.name)
    while 1:
        try:
            ser.write(b'hello')
            print('sent \n')
            time.sleep(0.2)
        except (SystemExit, KeyboardInterrupt):
            ser.close()
            sys.exit(0)

import serial
import time
import sys
import signal


def signal_handler(signal, frame):
    print('You pressed Ctrl+C!')
    sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
if __name__ == '__main__':
    ser = serial.Serial('/dev/ttyUSB0', 19200, timeout=1)
    print(ser.name)
    while 1:
        try:
            ser.write(b'hello')
            print('sent \n')
            time.sleep(0.2)
        except (SystemExit, KeyboardInterrupt):
            ser.close()
            sys.exit(0)

#!/usr/bin/env python
import serial
import time


import sys
import signal

def signal_handler(signal, frame): # ctrl + c -> exit program
        print('You pressed Ctrl+C!')
        sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)



if __name__ == '__main__':
  ser = serial.Serial('/dev/ttyUSB0', 19200, timeout=1)  # open serial port
  print(ser.name)         # check which port was really used
  while 1:
      try:
        ser.write(b'hello')     # write a string
        print("sent \n")
        time.sleep(0.2)
      except (SystemExit, KeyboardInterrupt) :
        ser.close()             # close port
        sys.exit(0)
