Created
March 24, 2016 15:30
-
-
Save dhhagan/ef257a4d5eae864cb709 to your computer and use it in GitHub Desktop.
Run the Alphasense OPC-N2 for 10 seconds in a loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple script to run the Alphasense OPC-N2 using the py-opc library. | |
Written by David H Hagan | March 24, 2016 | |
""" | |
import spidev | |
import opc | |
from time import sleep | |
# Set up a spidev instance | |
spi = spidev.SpiDev() | |
# Open the connection | |
spi.open(0, 0) | |
# Set the key variables | |
spi.mode = 1 | |
spi.max_speed_hz = 500000 | |
# Set up an instance of the OPCN2 class | |
alpha = opc.OPCN2(spi) | |
# Exit with ctrl+c | |
while True: | |
alpha.on() | |
# Sleep for 10 seconds | |
sleep(10) | |
# Turn off the OPC | |
alpha.off() | |
# Wait for 3 seconds before starting the cycle over | |
sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment