I am into playing with Arduino these days, and since I love Python, I had an idea of using both together. I did my research on Arduino and using Python with it and how both of them interact each other. I found out that you can use Python and Arduino together and using Python for Arduino might be easier for Python users who are interested in hardware stuffs to move Arduino stuffs. And I think by learning python with an Arduino, you will understand some advantage for both of them and your knowledge of Python might be deeper. However, there are some things you should do before you go out and do Arduino stuffs, so I tried to organize the first step for it in this article.
1. Please make sure that you already have Python 2 (https://www.python.org/downloads/release/python-2711/) ← (This link is the latest version of Python 2 so far). Then, you have to install a special library called “Pyserial” to communicate with the Arduino.
2. In order to get Pyserial, open the terminal on your computer, then try to code like this.
1 |
sudo pip install pyserial |
3. Open the python 2 shell, then try to put
1 |
import serial |
If you could not install both of them or either of them, you might get the error like this.
1 |
ImportError: No module named serial |
If you got this error message, go back to follow 1 to 3 again and please make sure whether you installed both of them correctly. (You might want to use another editor… Of course you can use it!)
4. Mission complete! You are ready to code!