How to import pyFirmata correctly?

2.2k Views Asked by At

I'm working on a project that involves experimenting with Arduino Mega and I'm learning about it from this book https://books.google.co.uk/books/about/Python_Programming_for_Arduino.html?id=O0PfBgAAQBAJ&printsec=frontcover&source=kp_read_button&redir_esc=y#v=onepage&q&f=false

I'm in a stage where I need to import pyfirmata library but for whatever reason it keeps throwing an import error.

I installed the library using pip3 and when that didn't help I built it from source therefore I'm quite confident that I've got it in my system. I even got a file path where it is installed. Within my Python site-packages directory.

The book is favouring Python 2.7 but I figured I can make this work in Python 3 as well. I tried import pyfirmata, from pyfirmata import Arduino and in both cases I get import error.

It shouldn't be that hard to get this to work. What should I try ?

#!/usr/bin/python
# Import required libraries
import  pyfirmata
from time import sleep

I also tried replacing the first line with the exact file path of the directory but no effect.

1

There are 1 best solutions below

0
On

you did everything needed with python but you also need to open Arduino IDE and press files, examples, Firmata, StandardFirmata then transfer the code to your board. Your board will now easily communicate with Python through the module Pyfirmata.