Sometimes when working on an Ardunio project, it is necessary to send data back and forth between a computer. Now, you could use something like the arduino ethernet shield, which would send data over a network, but if you want something easy and free the simplest solution is USB communication.
With serial.Serial('/dev/ttyS1', 19200, timeout=1) as ser. X = ser.read() # read one byte. S = ser.read(10) # read up to ten bytes (timeout). Line = ser.readline(). This module encapsulates the access for the serial port. Python 2.7 or newer, including Python 3.4 and newer; “Java Communications” (JavaComm).
There are several ways to approach Ardunio USB communication, but in this case we will be using Python on the computer side to send and receive information. As such, this instructable expects that you have some prior knowledge of Ardunio, and of Python (or other similar scripting language).
Why Python?
Python is a versatile, easy to learn, and easy to use scripting language. Its power, and huge library of user-created modules (everything from keyboard emulation to game programming) makes it an ideal language for a wide verity of computer side tasks. You could easy parse network information and make an Arduino visualizer, create a game controller, or make a keypad computer login system. Arduino with Python opens up a word of possibilities.