Raspberry Pi 3B+ 2 channel 5V Relay Board control Thonny GUI sample

Channel:
Subscribers:
48,800
Published on ● Video Link: https://www.youtube.com/watch?v=8g3S7P1tAdU



Duration: 0:35
94 views
10


#raspberrypi #raspberrypi3 #relayboard #gui
https://rpishop.cz/?loyaltyRef=2acced84740ebe1f61c7351c3390c87d&loyaltyRefId=99567
will test on raspberry 5 so more videos to come :)
Raspberry Pi 3B+ 2 channel 5 V Relay Board control Thonny GUI sample
2 channel 5V Relay Board pro Raspberry Pi
Raspberry Pi 3B+
useful link https://github.com/sbcshop/Zero-Relay
Sample code :
import tkinter as tk
import pizero_2relay as pizero


class RelayControlApp:
def __init__(self, master):
self.master = master
self.master.title("Relay Control")

# Připojení k relé
self.r1 = pizero.relay("R1")
self.r2 = pizero.relay("R2")

# Tlačítka pro ovládání relé
self.button_r1_on = tk.Button(master, text="Relay 1 ON", command=self.turn_on_r1)
self.button_r1_off = tk.Button(master, text="Relay 1 OFF", command=self.turn_off_r1)
self.button_r2_on = tk.Button(master, text="Relay 2 ON", command=self.turn_on_r2)
self.button_r2_off = tk.Button(master, text="Relay 2 OFF", command=self.turn_off_r2)

# Rozmístění tlačítek pomocí grid
self.button_r1_on.grid(row=0, column=0, padx=10, pady=5)
self.button_r1_off.grid(row=0, column=1, padx=10, pady=5)
self.button_r2_on.grid(row=1, column=0, padx=10, pady=5)
self.button_r2_off.grid(row=1, column=1, padx=10, pady=5)

def turn_on_r1(self):
self.r1.on()

def turn_off_r1(self):
self.r1.off()

def turn_on_r2(self):
self.r2.on()

def turn_off_r2(self):
self.r2.off()

if __name__ == "__main__":
root = tk.Tk()
app = RelayControlApp(root)
root.mainloop()







Tags:
2channel 5 V Relay Board
Raspberry Pi 3B+
Thonny GUI
Thonny GUI sample
5V Relay Board pro Raspberry Pi