Skip to end of banner
Go to start of banner

Python and the RevPi

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

A quick and easy introduction how to use the RevPi with the Python programming language.

Why Python?

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

Verwandte Artikel

  • No labels