A quick and easy introduction how to use the RevPi with the Python programming language.
Why Python?
Python is simple and straightforward
Documentation
Start interactive Python shell
python3
My recommendation use the ipython interactive shell as it supports tabbed auto completition
sudo apt install ipython3 ipython3
LED switch with Python
Works like writing a "1" to the location in the process image where the RevPiLED is located
Where is the RevPiLED located in the process image?
Run the following command
piTest -v RevPiLED
At offset 119
Example with Python
# ledswitch1.py f=open("/dev/piControl0","wb+",0) f.seek(119) f.write(b'1') f.seek(119) f.write(b'0')
RevPiModIO
Library developed from the RevPi community
Allows easy use of symbolic names from PiCtory
Installation not necessary already on the device
Documentation
Switch the LED with RevPiModIO
import revpimodio2 rpi = revpimodio2.RevPiModIO(autorefresh=True) rpi.io.RevPiLED.value = 1 rpi.io.RevPiLED.value = 0
Python I/O Bit Mirror
import revpimodio2 import time rpi = revpimodio2.RevPiModIO(autorefresh=True) while True: rpi.io.O_1.value = rpi.io.I_1.value time.sleep(0.02)
Video Tutorials
Also have a look at our video tutorials about Python
Also have a look at the following video tutorials