#这个程序主要是控制树莓派所连接的led灯

import tkinter as tk
import  RPi.GPIO as GPIO

chanel = int(input("chanel? "))#输入第一个led灯的GPIO口(BOARD),乱输可能会使你的树莓派变成一张信用卡大小的废物
chanel2 = int(input("chanel2? "))#输入第二个led灯的GPIO口(BOARD),乱输可能会使你的树莓派变成一张信用卡大小的废物
window = tk.Tk()
window.geometry("600x600")
window.title("RaspberryPi LED Manager")

l = tk.Label(window,text="RaspberryPi LED program",bg="green",width=200,height=2)
l.pack()

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(chanel, GPIO.OUT)#设置第chanel号为输出
GPIO.setup(chanel2, GPIO.OUT)#设置第chanel2号为输出

pwm = GPIO.PWM(chanel,100)#实例化对象pwm
pwm.start(0)#点灯，亮度为0
pwm2 = GPIO.PWM(chanel2,100)
pwm2.start(0)

l2 = tk.Label(window,text="",bg="yellow")
l2_2 = tk.Label(window,text="",bg="yellow")
def LEDON():#开灯(chanel)，亮度设置到100
    pwm.ChangeDutyCycle(100)
def LEDOFF():
    pwm.ChangeDutyCycle(0)#关灯(chanel)，亮度设置到0
def PWMLED(dc):#调节亮度(chanel)
    l2.config(text="(chanel) You have setted " + str(dc))
    dc = int(dc)
    pwm.ChangeDutyCycle(dc)

def LED2ON():#开灯(chanel2)，亮度设置到100
    pwm2.ChangeDutyCycle(100)
def LED2OFF():#关灯(chanel2)，亮度设置到0
    pwm2.ChangeDutyCycle(0)
def PWM2LED(dc):#调节亮度(chanel2)
    l2_2.config(text="(chanel2) You have setted " + str(dc))
    dc = int(dc)
    pwm2.ChangeDutyCycle(dc)


def STOPPWM():#清理所有GPIO口(在退出时运行，执行后所有操作将无效)
    GPIO.cleanup()

b1 = tk.Button(window,text="LED ON (chanel1)",bg="yellow",command=LEDON)#生成一个控制chanel的按钮
b1.pack()
b2 = tk.Button(window,text="LED OFF (chanel1)",bg="grey",command=LEDOFF)
b2.pack()

b1_2 = tk.Button(window,text="LED ON (chanel2)",bg="yellow",command=LED2ON)#生成一个控制chanel2的按钮
b1_2.pack()
b2_2 = tk.Button(window,text="LED OFF (chanel2)",bg="grey",command=LED2OFF)
b2_2.pack()


l2.pack()

l2_2.pack()

scale = tk.Scale(window,label="Pull Me (chanel1)",from_=0,to=100,orient=tk.HORIZONTAL,length=1000,showvalue=0,tickinterval=20,resolution=1,command=PWMLED)#生成一个控制chanel的条
scale.pack()
scale = tk.Scale(window,label="Pull Me (chanel2)",from_=0,to=100,orient=tk.HORIZONTAL,length=1000,showvalue=0,tickinterval=20,resolution=1,command=PWM2LED)#生成一个控制chanel2的条
scale.pack()

# b4 = tk.Button(window,text="start",command=STARTPWM)
b3 = tk.Button(window,text="stop",command=STOPPWM)#释放GPIO口
b3.pack()
# b4.pack()
window.mainloop()


# 我相信一定没有人会看到这个程序，注释写得很烂，见谅
175801b1f42c729fcbba2723e2e4fe88d96882be
<mask token>


def LEDON():
    pwm.ChangeDutyCycle(100)


def LEDOFF():
    pwm.ChangeDutyCycle(0)


def PWMLED(dc):
    l2.config(text='(chanel) You have setted ' + str(dc))
    dc = int(dc)
    pwm.ChangeDutyCycle(dc)


<mask token>


def LED2OFF():
    pwm2.ChangeDutyCycle(0)


def PWM2LED(dc):
    l2_2.config(text='(chanel2) You have setted ' + str(dc))
    dc = int(dc)
    pwm2.ChangeDutyCycle(dc)


def STOPPWM():
    GPIO.cleanup()


<mask token>

<mask token>


def LEDON():
    pwm.ChangeDutyCycle(100)


def LEDOFF():
    pwm.ChangeDutyCycle(0)


def PWMLED(dc):
    l2.config(text='(chanel) You have setted ' + str(dc))
    dc = int(dc)
    pwm.ChangeDutyCycle(dc)


def LED2ON():
    pwm2.ChangeDutyCycle(100)


def LED2OFF():
    pwm2.ChangeDutyCycle(0)


def PWM2LED(dc):
    l2_2.config(text='(chanel2) You have setted ' + str(dc))
    dc = int(dc)
    pwm2.ChangeDutyCycle(dc)


def STOPPWM():
    GPIO.cleanup()


<mask token>

<mask token>
window.geometry('600x600')
window.title('RaspberryPi LED Manager')
<mask token>
l.pack()
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(chanel, GPIO.OUT)
GPIO.setup(chanel2, GPIO.OUT)
<mask token>
pwm.start(0)
<mask token>
pwm2.start(0)
<mask token>


def LEDON():
    pwm.ChangeDutyCycle(100)


def LEDOFF():
    pwm.ChangeDutyCycle(0)


def PWMLED(dc):
    l2.config(text='(chanel) You have setted ' + str(dc))
    dc = int(dc)
    pwm.ChangeDutyCycle(dc)


def LED2ON():
    pwm2.ChangeDutyCycle(100)


def LED2OFF():
    pwm2.ChangeDutyCycle(0)


def PWM2LED(dc):
    l2_2.config(text='(chanel2) You have setted ' + str(dc))
    dc = int(dc)
    pwm2.ChangeDutyCycle(dc)


def STOPPWM():
    GPIO.cleanup()


<mask token>
b1.pack()
<mask token>
b2.pack()
<mask token>
b1_2.pack()
<mask token>
b2_2.pack()
l2.pack()
l2_2.pack()
<mask token>
scale.pack()
<mask token>
scale.pack()
<mask token>
b3.pack()
window.mainloop()

import tkinter as tk
import RPi.GPIO as GPIO
chanel = int(input('chanel? '))
chanel2 = int(input('chanel2? '))
window = tk.Tk()
window.geometry('600x600')
window.title('RaspberryPi LED Manager')
l = tk.Label(window, text='RaspberryPi LED program', bg='green', width=200,
    height=2)
l.pack()
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(chanel, GPIO.OUT)
GPIO.setup(chanel2, GPIO.OUT)
pwm = GPIO.PWM(chanel, 100)
pwm.start(0)
pwm2 = GPIO.PWM(chanel2, 100)
pwm2.start(0)
l2 = tk.Label(window, text='', bg='yellow')
l2_2 = tk.Label(window, text='', bg='yellow')


def LEDON():
    pwm.ChangeDutyCycle(100)


def LEDOFF():
    pwm.ChangeDutyCycle(0)


def PWMLED(dc):
    l2.config(text='(chanel) You have setted ' + str(dc))
    dc = int(dc)
    pwm.ChangeDutyCycle(dc)


def LED2ON():
    pwm2.ChangeDutyCycle(100)


def LED2OFF():
    pwm2.ChangeDutyCycle(0)


def PWM2LED(dc):
    l2_2.config(text='(chanel2) You have setted ' + str(dc))
    dc = int(dc)
    pwm2.ChangeDutyCycle(dc)


def STOPPWM():
    GPIO.cleanup()


b1 = tk.Button(window, text='LED ON (chanel1)', bg='yellow', command=LEDON)
b1.pack()
b2 = tk.Button(window, text='LED OFF (chanel1)', bg='grey', command=LEDOFF)
b2.pack()
b1_2 = tk.Button(window, text='LED ON (chanel2)', bg='yellow', command=LED2ON)
b1_2.pack()
b2_2 = tk.Button(window, text='LED OFF (chanel2)', bg='grey', command=LED2OFF)
b2_2.pack()
l2.pack()
l2_2.pack()
scale = tk.Scale(window, label='Pull Me (chanel1)', from_=0, to=100, orient
    =tk.HORIZONTAL, length=1000, showvalue=0, tickinterval=20, resolution=1,
    command=PWMLED)
scale.pack()
scale = tk.Scale(window, label='Pull Me (chanel2)', from_=0, to=100, orient
    =tk.HORIZONTAL, length=1000, showvalue=0, tickinterval=20, resolution=1,
    command=PWM2LED)
scale.pack()
b3 = tk.Button(window, text='stop', command=STOPPWM)
b3.pack()
window.mainloop()

#这个程序主要是控制树莓派所连接的led灯

import tkinter as tk
import  RPi.GPIO as GPIO

chanel = int(input("chanel? "))#输入第一个led灯的GPIO口(BOARD),乱输可能会使你的树莓派变成一张信用卡大小的废物
chanel2 = int(input("chanel2? "))#输入第二个led灯的GPIO口(BOARD),乱输可能会使你的树莓派变成一张信用卡大小的废物
window = tk.Tk()
window.geometry("600x600")
window.title("RaspberryPi LED Manager")

l = tk.Label(window,text="RaspberryPi LED program",bg="green",width=200,height=2)
l.pack()

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(chanel, GPIO.OUT)#设置第chanel号为输出
GPIO.setup(chanel2, GPIO.OUT)#设置第chanel2号为输出

pwm = GPIO.PWM(chanel,100)#实例化对象pwm
pwm.start(0)#点灯，亮度为0
pwm2 = GPIO.PWM(chanel2,100)
pwm2.start(0)

l2 = tk.Label(window,text="",bg="yellow")
l2_2 = tk.Label(window,text="",bg="yellow")
def LEDON():#开灯(chanel)，亮度设置到100
    pwm.ChangeDutyCycle(100)
def LEDOFF():
    pwm.ChangeDutyCycle(0)#关灯(chanel)，亮度设置到0
def PWMLED(dc):#调节亮度(chanel)
    l2.config(text="(chanel) You have setted " + str(dc))
    dc = int(dc)
    pwm.ChangeDutyCycle(dc)

def LED2ON():#开灯(chanel2)，亮度设置到100
    pwm2.ChangeDutyCycle(100)
def LED2OFF():#关灯(chanel2)，亮度设置到0
    pwm2.ChangeDutyCycle(0)
def PWM2LED(dc):#调节亮度(chanel2)
    l2_2.config(text="(chanel2) You have setted " + str(dc))
    dc = int(dc)
    pwm2.ChangeDutyCycle(dc)


def STOPPWM():#清理所有GPIO口(在退出时运行，执行后所有操作将无效)
    GPIO.cleanup()

b1 = tk.Button(window,text="LED ON (chanel1)",bg="yellow",command=LEDON)#生成一个控制chanel的按钮
b1.pack()
b2 = tk.Button(window,text="LED OFF (chanel1)",bg="grey",command=LEDOFF)
b2.pack()

b1_2 = tk.Button(window,text="LED ON (chanel2)",bg="yellow",command=LED2ON)#生成一个控制chanel2的按钮
b1_2.pack()
b2_2 = tk.Button(window,text="LED OFF (chanel2)",bg="grey",command=LED2OFF)
b2_2.pack()


l2.pack()

l2_2.pack()

scale = tk.Scale(window,label="Pull Me (chanel1)",from_=0,to=100,orient=tk.HORIZONTAL,length=1000,showvalue=0,tickinterval=20,resolution=1,command=PWMLED)#生成一个控制chanel的条
scale.pack()
scale = tk.Scale(window,label="Pull Me (chanel2)",from_=0,to=100,orient=tk.HORIZONTAL,length=1000,showvalue=0,tickinterval=20,resolution=1,command=PWM2LED)#生成一个控制chanel2的条
scale.pack()

# b4 = tk.Button(window,text="start",command=STARTPWM)
b3 = tk.Button(window,text="stop",command=STOPPWM)#释放GPIO口
b3.pack()
# b4.pack()
window.mainloop()


# 我相信一定没有人会看到这个程序，注释写得很烂，见谅