exixe Raspberry Pi/Python library
This is a simple Python library for exixe modules intended to be used on a Raspberry Pi.
Requirements
In order to use this library, you must have python installed, SPI interface turned on the Raspberry Pi and spidev python library installed.
Configuration
Turning on SPI
The SPI peripheral is not turned on by default. To enable it, do the following.
- Run sudo raspi-config.
- Use the down arrow to select 5 Interfacing Options
- Arrow down to P4 SPI.
- Select yes when it asks you to enable SPI,
- Also select yes if it asks about automatically loading the kernel module.
- Use the right arrow to select the < Finish > button.
- Select yes when it asks to reboot.
Installing spidev
From pip:
pip install spidev
From source:
sudo apt-get update sudo apt-get install python-dev
git clone git://github.com/doceme/py-spidev
cd py-spidev
sudo python setup.py install
sudo python3 setup.py install
Usage
The code has some good documentation that I dont want to repeat but this will be a general overview on how to use the library.
- Create SPI initialization
spi = spidev.SpiDev()
spi.open(0,0)
spi.max_speed = 7800000
- Identify CS pin to control the individual exixe
- Create exixe object
exixe_1 = Exixe(cs_pin,spi)
- Control object
exixe_1.set_digit(5)
exixe_1.set_led(127,0,0) # turn led to red