How to control electronic external devices by your computer - USB , Relay

  Рет қаралды 22

Educating using technology and engineering

Educating using technology and engineering

Күн бұрын

How to control electronic external devices by your computer - USB , Relay
• How to control electro...
#USBRelay #Automation #TechTutorial #DIYElectronics #SmartHome #RelayControl #PCAutomation
ex 1
import os
Replace this with the correct Device Instance ID from Device Manager
inst = r"USB\VID_090C&PID_1000\6&371EC0B8&0&2"
import subprocess
def usb_power_windows(state):
"""Enable or disable USB power on Windows."""
if state == "off":
command = f"powershell.exe Disable-PnpDevice -InstanceId '{inst}' -Confirm:$false"
elif state == "on":
command = f"powershell.exe Enable-PnpDevice -InstanceId '{inst}' -Confirm:$false"
else:
print("Invalid state. Use 'on' or 'off'.")
return
Run the command
result = subprocess.run(command, shell=True, capture_output=True, text=True)
Check for errors
if result.returncode != 0:
print(f"Error: {result.stderr}")
else:
print(result.stdout)
Example usage
try:
x = int(input("Enter 1 for ON & 2 for OFF: "))
if x == 1:
usb_power_windows("on")
print("USB turned ON")
elif x == 2:
usb_power_windows("off")
print("USB turned OFF")
else:
print("No valid selection made.")
except ValueError:
print("Invalid input. Please enter 1 or 2.")
ex 2
import os
Replace this with the correct Device Instance ID from Device Manager
inst = r"USB\VID_090C&PID_1000\6&371EC0B8&0&2"
def usb_power_windows(state, inst):
"""Enable or disable USB power on Windows."""
if state == "off":
os.system(f"powershell.exe Disable-PnpDevice -InstanceId {inst} -Confirm:$false")
print("USB Power OFF")
elif state == "on":
os.system(f"powershell.exe Enable-PnpDevice -InstanceId {inst} -Confirm:$false")
print("USB Power ON")
else:
print("Invalid state. Use 'on' or 'off'.")
Example usage
x = int(input("Enter 1 for ON & 2 for OFF: "))
if x == 1:
usb_power_windows("on", inst)
elif x == 2:
usb_power_windows("off", inst)
else:
print("No valid selection.")
How to Control USB & Relay Devices from Your PC
USB & Relay Automation: Control Electronics with Your Computer
Mastering USB Relay Control for Home & Industrial Use
Automate External Devices via USB & Relay Modules
Turn Your PC into a Smart Controller: USB & Relay Guide
DIY USB Relay Control: Step-by-Step Tutorial
How to Use a Relay with USB for Smart Automation
Learn how to control external electronic devices using your computer via USB and relay modules! This tutorial explains the step-by-step process to turn your PC into a powerful automation tool. Whether for home automation, industrial applications, or DIY projects, this guide will help you master USB relay control efficiently. Subscribe for more tech and automation tips!
USB relay, relay control, computer automation, USB power switch, home automation, external device control, DIY electronics, smart automation, USB relay module, relay switching, USB controlled relay, Python USB relay, Windows relay control, power control, IoT automation, home tech, industrial automation, smart relay, PC controlled relay, USB electronics, Raspberry Pi relay, Arduino alternative, relay programming, Python relay control, USB power automation, control circuit, USB relay projects, electronics hacking, automation tutorial, USB on/off switch

Пікірлер
NEVER install these programs on your PC... EVER!!!
19:26
JayzTwoCents
Рет қаралды 4,9 МЛН
Insane Theoretical Physics Discussion with ChatGPT and DeepSeek
4:59
Unzicker's Real Physics
Рет қаралды 35 М.
Bungee Jumping With Rope In Beautiful Place:Asmr Bungee Jumping
00:14
Bungee Jumping Park Official
Рет қаралды 17 МЛН
Версия без цензуры в 🛒 МИРАКЛЯНДИЯ
00:47
ПОДРИФТИЛ С БАБУЛЕЙ #shorts
00:22
Паша Осадчий
Рет қаралды 2,5 МЛН
What if all the world's biggest problems have the same solution?
24:52
Making Simple Windows Driver in C
7:26
Nir Lichtman
Рет қаралды 377 М.
Full video - Data recovery from a dead MicroSD card
16:01
DevelopAKR
Рет қаралды 521 М.
I Spent 100 Hours Inside The Pyramids!
21:43
MrBeast
Рет қаралды 78 МЛН
China announces retaliatory tariffs on US goods
5:29
Al Jazeera English
Рет қаралды 228 М.
Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files
16:12
Wireshark for BEGINNERS // Where to start with Wireshark
16:14
Chris Greer
Рет қаралды 849 М.
Bungee Jumping With Rope In Beautiful Place:Asmr Bungee Jumping
00:14
Bungee Jumping Park Official
Рет қаралды 17 МЛН