Documentation by Orwa
- Components
- Wiring Diagram
- Prerequisites (installation)
- Usage instructions (as a libary)
- Usage instructions (from the command line)
- Hardware
- relay_sketch.ino
- relay.py
- PySerial package. To install type the following from the command prompt:
"pip install pyserial"
- Launch "idle" on windows
- Type: "import os:print(os.getcwd())"
- Copy "relay.py" to subdirectory "Lib" within the folder above (displayed in idle in blue)
- Now you can use the libary using "import relay" then calling the following functions:
- relay.turn_on(): turns the relay on
- relay.turn_off(): turns the relay off
- Note that if the hardware is not connected then an exception will be thrown when importing the libary
- Note that if the hardware is connected but being used by another program, an exception will also be thrown when importing the libary
- To turn on the relay from the command line, go to the folder where "relay.py" is stored and type the following commands:
- "python relay.py 1" turns the relay on
- "python relay.py 0" turns the relay off
- Note that if the hardware is not connected, an error message will be displayed.
- Note that if the hardware is connected but being used by another program, an error message will be displayed.