Skip to content

odiraneyya/USB-to-Relay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Relay Control Via Serial

Documentation by Orwa

Content

Components

  1. Hardware
  2. relay_sketch.ino
  3. relay.py

Wiring Diagram

Wiring Diagram

Prerequisites (installation)

  1. PySerial package. To install type the following from the command prompt:

    "pip install pyserial"

Usage instructions (as a libary)

  1. Launch "idle" on windows
  2. Type: "import os:print(os.getcwd())" Python Screenshot
  3. Copy "relay.py" to subdirectory "Lib" within the folder above (displayed in idle in blue)
  4. Now you can use the libary using "import relay" then calling the following functions:
    1. relay.turn_on(): turns the relay on
    2. relay.turn_off(): turns the relay off
  5. Note that if the hardware is not connected then an exception will be thrown when importing the libary
  6. Note that if the hardware is connected but being used by another program, an exception will also be thrown when importing the libary

Usage instructions (from the command line)

  1. To turn on the relay from the command line, go to the folder where "relay.py" is stored and type the following commands:
    1. "python relay.py 1" turns the relay on
    2. "python relay.py 0" turns the relay off
  2. Note that if the hardware is not connected, an error message will be displayed.
  3. Note that if the hardware is connected but being used by another program, an error message will be displayed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published