Python + Arduino? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Python + Arduino?

Hi, I've though about programming an interface with python to controlling the Arduino's board and try read someone sensor. Is it possible? I think yes, but, where can I find such information? Thank you for read this, and I'm really sorry if you can't understand me, because, It's my first post in english.

9th Oct 2017, 11:47 PM
Marito
Marito - avatar
4 Answers
+ 4
I think maybe not. Arduino uses C++-styled syntax
9th Oct 2017, 11:51 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
your interface needs to communicate with the microcontroller through serial port. You'll need pyserial python module example your python program on the PC sends "ready" over the serual port. The arduino reads the incoming data om the serial buffer and, if it equals to "ready", sends back the sensor data. Upon receiving the sensor data, your python program updates what is displayed with the freshly received info. After that the python program sends "ready" again and the whole process repeats. There are tons of tutorials on line: this is one of my favourites: This guy has a nice set of tutorials about a 3d virtual recreation with python of the data sensed by the arduino (distance and color) https://m.youtube.com/watch?v=rE84gJUZGO8 Serial is the easiest method as you do not need additional hardware: your usb cable will do. If you don't want to develop your own communication protocol have a look at FIRMATA. You can also set up a server and communicate via ethernet or wifi but that will require additional hardware.
10th Oct 2017, 12:09 AM
seamiki
seamiki - avatar
0
yes I know, but, if I could read the serial port and take sensor's information with an interface, and it made with python.
9th Oct 2017, 11:57 PM
Marito
Marito - avatar
0
I hope it work, and I'm not a expert on python but I think there's some place where they explain about communication between python and USB port.
10th Oct 2017, 12:03 AM
Marito
Marito - avatar