In this Tutorial we are going to list all the requirements and demonstrate an example whish illustrate the full control of the Arduino board from a PC or any raspberry pi …
Preliminaries
- Install python and pip.
- Go to the Arduino IDE and transfer the Firmata code into the Arduino.
The code
This code is made for windows, in Linux you have to use /dev/ttyusb0
for example, or select the appropriate one from the list by typing: ls /dev/*
import pyfirmata import time board = pyfirmata.Arduino('COM7') // 'COMX' for Ports in windows while True: board.digital[13].write(1) time.sleep(5) board.digital[13].write(0) time.sleep(1)
This code will blink on and off the onborad LED on the arduino which is connected to the pin #13.