Skip to content

Latest commit

 

History

History
123 lines (97 loc) · 4.33 KB

README.md

File metadata and controls

123 lines (97 loc) · 4.33 KB

PiServoHat_Py

follow on Twitter

SparkFun Servo pHAT for the Raspberry Pi

Python module for the SparkFun Servo pHAT for Raspberry Pi and SparkFun Pi Servo HAT

This package should be used in conjunction with the overall SparkFun qwiic Python Package. New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.

Contents

Supported Platforms

The PiServoHat Python package current supports the following platforms:

Dependencies

This package depends on the qwiic I2C driver: Qwiic_I2C_Py

This package depends on the PCA9685 PWM controller: Qwiic_PCA9685_Py

Documentation

The SparkFun PiServoHat module documentation is hosted at ReadTheDocs

Installation

PyPi Installation

This repository is hosted on PyPi as the sparkfun-pi-servo-hat package. On systems that support PyPi installation via pip, this library is installed using the following commands

For all users (note: the user must have sudo privileges):

sudo pip install sparkfun-pi-servo-hat

For the current user:

pip install sparkfun-pi-servo-hat

Local Installation

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line:

python setup.py install

To build a package for use with pip:

python setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.

cd dist
pip install sparkfun_pi-servo-hat-<version>.tar.gz
  

Example Use (to be editted)

See the examples directory for more detailed use examples.

import pi_servo_hat
import time
import sys

def runExample():

	print("\nSparkFun Pi Servo Hat Demo\n")
	mySensor = pi_servo_hat.PiServoHat()

	if mySensor.isConnected() == False:
		print("The Qwiic PCA9685 device isn't connected to the system. Please check your connection", \
			file=sys.stderr)
		return

	mySensor.restart()
  
	# Test Run
	#########################################
	# Moves servo position to 0 degrees (1ms), Channel 0
	mySensor.move_servo_position(0, 0)

	# Pause 1 sec
	time.sleep(1)

	# Moves servo position to 90 degrees (2ms), Channel 0
	mySensor.move_servo_position(0, 90)

SparkFun - Start Something