├── Example 1 ListPort
├── Example 1 List serialPort.ui
├── Example_ListPort.py
└── ListPort.wmv
├── Example 2 OpenPort
├── ConnectPort.wmv
├── Example 2 Open serialPort.ui
└── Example_OpeningPort.py
├── Example 3 Reading data from Serial Port
├── Example 3 Reading serialPort.ui
├── Example_ReadDataPort.py
└── ReadDataserialPort.wmv
├── Example 4 Clock
├── Clock.wmv
├── Example 4 Clock.ui
└── Example Clock.py
├── Example 5 On-Off Relay Simulation
├── ControlRelay.wmv
├── Example 5 ONOFF_Relay.ui
├── Example_ONOFF_Relay.py
└── Pyduino_ControlRelay
│ └── Pyduino_ControlRelay.ino
├── Proteus Simulator
├── PyduinoSim.pdsprj
└── readme
├── Pyduino.ino
└── Pyduino.ino
├── PyduinoGUI
├── Icon
│ ├── Pyduino_img.png
│ ├── cancel.png
│ ├── facebook.png
│ └── leaf.png
├── Pyduino.py
├── Pyduino.ui
└── __pycache__
│ └── testThead.cpython-39.pyc
└── README.md
/Example 1 ListPort/Example 1 List serialPort.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 255
10 | 172
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 0
21 | 0
22 | 251
23 | 151
24 |
25 |
26 |
27 | Serial Port
28 |
29 |
30 |
31 |
32 | 40
33 | 90
34 | 161
35 | 22
36 |
37 |
38 |
39 |
40 |
41 |
42 | 40
43 | 70
44 | 47
45 | 13
46 |
47 |
48 |
49 | Comport
50 |
51 |
52 |
53 |
54 |
55 | 50
56 | 20
57 | 151
58 | 31
59 |
60 |
61 |
62 |
63 | TH SarabunPSK
64 | 16
65 |
66 |
67 |
68 | แสดงพอร์ตอนุกรมที่ค้นพบ
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/Example 1 ListPort/Example_ListPort.py:
--------------------------------------------------------------------------------
1 | #นำไลบรารี่ pyserial เข้ามาใช้งาน
2 | #และไลบรารี่คำสั่งของ Qt Designer
3 | import serial
4 | import serial.tools.list_ports
5 | from PyQt5 import QtWidgets, uic
6 |
7 |
8 | app = QtWidgets.QApplication([])
9 | ui = uic.loadUi("Example 1 List serialPort.ui") #ตั้งให้ตรงกับชื่อไฟล์ Qt Designer
10 |
11 | Pyserial = serial.Serial() #ประกาศตัวแปร Pyserial เพื่อรับค่าจากพอร์ตอนุกรม
12 | ports = serial.tools.list_ports.comports() #ประกาศตัวแปร ports สำหรับเก็บรายการคอมพอร์ต
13 | portList = [] #ประกาศตัวแปร portList สำหรับเก็บค่าพอร์ตที่อ่านได้
14 | for port in ports: #for loop สำหรับวนรอบการค้นหาพอร์ต
15 | portList.append(port[0]) #นำตัวแปร port มาแสดงใน portList
16 |
17 | ui.cmb_port.addItems(portList) #นำค่า portList ทีไ่ด้ไปแสดงใน Combo Box
18 |
19 | ui.show() #แสดง ui
20 | app.exec() #รันแอป
21 |
--------------------------------------------------------------------------------
/Example 1 ListPort/ListPort.wmv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/Example 1 ListPort/ListPort.wmv
--------------------------------------------------------------------------------
/Example 2 OpenPort/ConnectPort.wmv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/Example 2 OpenPort/ConnectPort.wmv
--------------------------------------------------------------------------------
/Example 2 OpenPort/Example 2 Open serialPort.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 255
10 | 172
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 0
21 | 0
22 | 251
23 | 151
24 |
25 |
26 |
27 | Serial Port
28 |
29 |
30 |
31 |
32 | 40
33 | 90
34 | 161
35 | 22
36 |
37 |
38 |
39 |
40 |
41 |
42 | 40
43 | 70
44 | 47
45 | 13
46 |
47 |
48 |
49 | Comport
50 |
51 |
52 |
53 |
54 |
55 | 50
56 | 20
57 | 151
58 | 31
59 |
60 |
61 |
62 |
63 | TH SarabunPSK
64 | 16
65 |
66 |
67 |
68 | แสดงพอร์ตอนุกรมที่ค้นพบ
69 |
70 |
71 |
72 |
73 |
74 | 40
75 | 120
76 | 75
77 | 31
78 |
79 |
80 |
81 | Connect
82 |
83 |
84 |
85 |
86 |
87 | 120
88 | 120
89 | 75
90 | 31
91 |
92 |
93 |
94 | Disconnect
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/Example 2 OpenPort/Example_OpeningPort.py:
--------------------------------------------------------------------------------
1 | #นำไลบรารี่ pyserial เข้ามาใช้งาน
2 | #และไลบรารี่คำสั่งของ Qt Designer
3 | import serial
4 | import serial.tools.list_ports
5 | from PyQt5 import QtWidgets, uic
6 |
7 | app = QtWidgets.QApplication([])
8 | ui = uic.loadUi("Example 2 Open serialPort.ui") #ตั้งให้ตรงกับชื่อไฟล์ Qt Designer
9 |
10 | Pyserial = serial.Serial() #ประกาศตัวแปร Pyserial เพื่อรับค่าจากพอร์ตอนุกรม
11 | ports = serial.tools.list_ports.comports() #ประกาศตัวแปร ports สำหรับเก็บรายการคอมพอร์ต
12 | portList = [] #ประกาศตัวแปร portList สำหรับเก็บค่าพอร์ตที่อ่านได้
13 | for port in ports: #for loop สำหรับวนรอบการค้นหาพอร์ต
14 | portList.append(port[0]) #นำตัวแปร port มาแสดงใน portList
15 |
16 | def openPort(): #ฟังก์ชันการปิดพอร์ต
17 | Pyserial.port = ui.cmb_port.currentText() #ให้ตัวแปร Pyserial มีค่าเท่ากับค่าที่แสดงบน Combo Box
18 | Pyserial.baudrate = 9600 #เปิดพอร์ตสื่อสารที่อัตรา 9600
19 | Pyserial.open() #เปิดพอร์ต
20 | ui.btn_connect.setEnabled(False) #เมื่อมีการกดปุ่ม Connect ให้ปุ่ม Disable
21 | ui.btn_disconnect.setEnabled(True) #เมื่อมีการกดปุ่ม Disconnect ให้ปุ่ม Disable
22 | if Pyserial.isOpen():
23 | print("Open port with : " + str(ui.cmb_port.currentText())) #แสดงข้อความผ่านดีบัค
24 |
25 | def closePort(): #ฟังก์ชันการปิดพอร์ต
26 | Pyserial.close()
27 | ui.btn_connect.setEnabled(True) #เมื่อมีการกดปุ่ม Disconnect ให้ปุ่ม Connect enable
28 | ui.btn_disconnect.setEnabled(False) #เมื่อมีการกดปุ่ม Disconnect ให้ปุ่ม Disconnect Disable
29 | print("Disconnect port with : " + str(ui.cmb_port.currentText())) #แสดงข้อความผ่านดีบัค
30 |
31 | ui.cmb_port.addItems(portList) #นำค่า portList ทีไ่ด้ไปแสดงใน Combo Box
32 | ui.btn_connect.clicked.connect(openPort) #ปุ่มเปิดพอร์ต
33 | ui.btn_disconnect.clicked.connect(closePort) #ปุ่มปิดพอร์ต
34 |
35 | ui.show() #แสดง ui
36 | app.exec() #รันแอป
37 |
--------------------------------------------------------------------------------
/Example 3 Reading data from Serial Port/Example 3 Reading serialPort.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 257
10 | 175
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 0
21 | 0
22 | 251
23 | 151
24 |
25 |
26 |
27 | Serial Port
28 |
29 |
30 |
31 |
32 | 40
33 | 90
34 | 161
35 | 22
36 |
37 |
38 |
39 |
40 |
41 |
42 | 40
43 | 70
44 | 47
45 | 13
46 |
47 |
48 |
49 | Comport
50 |
51 |
52 |
53 |
54 |
55 | 50
56 | 20
57 | 151
58 | 31
59 |
60 |
61 |
62 |
63 | TH SarabunPSK
64 | 16
65 |
66 |
67 |
68 | แสดงพอร์ตอนุกรมที่ค้นพบ
69 |
70 |
71 |
72 |
73 |
74 | 40
75 | 120
76 | 75
77 | 31
78 |
79 |
80 |
81 | Connect
82 |
83 |
84 |
85 |
86 |
87 | 120
88 | 120
89 | 75
90 | 31
91 |
92 |
93 |
94 | Disconnect
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/Example 3 Reading data from Serial Port/Example_ReadDataPort.py:
--------------------------------------------------------------------------------
1 | #นำไลบรารี่ pyserial เข้ามาใช้งาน
2 | #และไลบรารี่คำสั่งของ Qt Designer
3 | import serial
4 | import serial.tools.list_ports
5 | from PyQt5 import QtWidgets, uic
6 | from PyQt5.QtCore import QTime, QTimer
7 |
8 | app = QtWidgets.QApplication([])
9 | ui = uic.loadUi("Example 3 Reading serialPort.ui") #ตั้งให้ตรงกับชื่อไฟล์ Qt Designer
10 |
11 | Pyserial = serial.Serial() #ประกาศตัวแปร Pyserial เพื่อรับค่าจากพอร์ตอนุกรม
12 | ports = serial.tools.list_ports.comports() #ประกาศตัวแปร ports สำหรับเก็บรายการคอมพอร์ต
13 | portList = [] #ประกาศตัวแปร portList สำหรับเก็บค่าพอร์ตที่อ่านได้
14 | for port in ports: #for loop สำหรับวนรอบการค้นหาพอร์ต
15 | portList.append(port[0]) #นำตัวแปร port มาแสดงใน portList
16 |
17 | def openPort(): #ฟังก์ชันการปิดพอร์ต
18 | Pyserial.port = ui.cmb_port.currentText() #ให้ตัวแปร Pyserial มีค่าเท่ากับค่าที่แสดงบน Combo Box
19 | Pyserial.baudrate = 9600 #เปิดพอร์ตสื่อสารที่อัตรา 9600
20 | Pyserial.open() #เปิดพอร์ต
21 | ui.btn_connect.setEnabled(False) #เมื่อมีการกดปุ่ม Connect ให้ปุ่ม Disable
22 | ui.btn_disconnect.setEnabled(True) #เมื่อมีการกดปุ่ม Disconnect ให้ปุ่ม Disable
23 | if Pyserial.isOpen():
24 | print("Open port with : " + str(ui.cmb_port.currentText())) #แสดงข้อความผ่านดีบัค
25 |
26 | def closePort(): #ฟังก์ชันการปิดพอร์ต
27 | Pyserial.close()
28 | ui.btn_connect.setEnabled(True) #เมื่อมีการกดปุ่ม Disconnect ให้ปุ่ม Connect enable
29 | ui.btn_disconnect.setEnabled(False) #เมื่อมีการกดปุ่ม Disconnect ให้ปุ่ม Disconnect Disable
30 | print("Disconnect port with : " + str(ui.cmb_port.currentText())) #แสดงข้อความผ่านดีบัค
31 |
32 | #Read data incomming form uart
33 | def rxBuffer():
34 | if Pyserial.isOpen():
35 | global Data_buffer
36 | Data = Pyserial.readline().strip().decode('utf-8')
37 | Data_buffer = Data.split(",") #แบ่งข้อมูลด้วย comma
38 | print("Data incomming : " + str(Data_buffer))
39 |
40 | readRx = QTimer()
41 | readRx.timeout.connect(rxBuffer)
42 | readRx.start(1)
43 |
44 | ui.cmb_port.addItems(portList) #นำค่า portList ทีไ่ด้ไปแสดงใน Combo Box
45 | ui.btn_connect.clicked.connect(openPort) #ปุ่มเปิดพอร์ต
46 | ui.btn_disconnect.clicked.connect(closePort) #ปุ่มปิดพอร์ต
47 |
48 | ui.show() #แสดง ui
49 | app.exec() #รันแอป
50 |
--------------------------------------------------------------------------------
/Example 3 Reading data from Serial Port/ReadDataserialPort.wmv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/Example 3 Reading data from Serial Port/ReadDataserialPort.wmv
--------------------------------------------------------------------------------
/Example 4 Clock/Clock.wmv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/Example 4 Clock/Clock.wmv
--------------------------------------------------------------------------------
/Example 4 Clock/Example 4 Clock.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 480
10 | 261
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 70
21 | 100
22 | 341
23 | 121
24 |
25 |
26 |
27 |
28 |
29 |
30 | 8
31 |
32 |
33 | 0
34 |
35 |
36 |
37 |
38 |
39 | 110
40 | 30
41 | 261
42 | 61
43 |
44 |
45 |
46 |
47 | TH SarabunPSK
48 | 36
49 | 75
50 | true
51 |
52 |
53 |
54 | Real Time Clock
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/Example 4 Clock/Example Clock.py:
--------------------------------------------------------------------------------
1 | from PyQt5.QtCore import QTime, QTimer
2 | from PyQt5 import QtWidgets, uic
3 |
4 | app = QtWidgets.QApplication([])
5 | ui = uic.loadUi("Example 4 Clock.ui")
6 |
7 | def clock():
8 | currentTime = QTime.currentTime() #ให้ตัวแปร currentTime รับค่าจากฟังก์ชัน QTime.currentTime()
9 | currentTimeText = currentTime.toString('hh:mm:ss') #ให้ตัวแปร currentTimeText รับค่าเวลาปัจจุบัน
10 | ui.lcdClock.display(currentTimeText) #แสดงค่าบนจอ LCD
11 |
12 | timer = QTimer(); #สร้างคัวแปร timer สำหรับฟังก์ชัน QTimer()
13 | timer.timeout.connect(clock) #ให้ timer เรียกใช้ method clock
14 | timer.start() #เริ่มต้นการทำงานแสดงเวลา
15 |
16 | ui.show() #แสดงผล UI
17 | app.exec() #รันแอป
18 |
--------------------------------------------------------------------------------
/Example 5 On-Off Relay Simulation/ControlRelay.wmv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/Example 5 On-Off Relay Simulation/ControlRelay.wmv
--------------------------------------------------------------------------------
/Example 5 On-Off Relay Simulation/Example 5 ONOFF_Relay.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 369
10 | 234
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | 30
21 | 20
22 | 311
23 | 81
24 |
25 |
26 |
27 | 8
28 |
29 |
30 |
31 |
32 |
33 | 30
34 | 110
35 | 71
36 | 21
37 |
38 |
39 |
40 |
41 | TH SarabunPSK
42 | 20
43 | 75
44 | true
45 |
46 |
47 |
48 | เวลาเปิด
49 |
50 |
51 |
52 |
53 |
54 | 250
55 | 110
56 | 71
57 | 21
58 |
59 |
60 |
61 |
62 | TH SarabunPSK
63 | 20
64 | 75
65 | true
66 |
67 |
68 |
69 | เวลาปิด
70 |
71 |
72 |
73 |
74 |
75 | 30
76 | 170
77 | 42
78 | 22
79 |
80 |
81 |
82 | 23
83 |
84 |
85 |
86 |
87 |
88 | 80
89 | 170
90 | 42
91 | 22
92 |
93 |
94 |
95 | 59
96 |
97 |
98 |
99 |
100 |
101 | 250
102 | 170
103 | 42
104 | 22
105 |
106 |
107 |
108 | 23
109 |
110 |
111 |
112 |
113 |
114 | 300
115 | 170
116 | 42
117 | 22
118 |
119 |
120 |
121 | 59
122 |
123 |
124 |
125 |
126 |
127 | 30
128 | 150
129 | 31
130 | 16
131 |
132 |
133 |
134 | ชั่วโมง
135 |
136 |
137 |
138 |
139 |
140 | 80
141 | 150
142 | 31
143 | 16
144 |
145 |
146 |
147 | นาที
148 |
149 |
150 |
151 |
152 |
153 | 250
154 | 150
155 | 31
156 | 16
157 |
158 |
159 |
160 | ชั่วโมง
161 |
162 |
163 |
164 |
165 |
166 | 300
167 | 150
168 | 31
169 | 16
170 |
171 |
172 |
173 | นาที
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/Example 5 On-Off Relay Simulation/Example_ONOFF_Relay.py:
--------------------------------------------------------------------------------
1 | from PyQt5 import QtWidgets, uic
2 | import serial
3 | import serial.tools.list_ports
4 | from PyQt5.QtCore import QTime, QTimer
5 |
6 | app = QtWidgets.QApplication([])
7 | ui = uic.loadUi("Example 5 ONOFF_Relay.ui")
8 |
9 | Hon = []; Mon = []; Hoff = []; Moff = [] #ประกาศตัวแปรสำหรับจองค่าเวลา
10 | Hon = [0 for i in range(20)] #ให้ตัวแปร Hon มีค่าเริ่มต้นเป็น 0 ทั้งหมด
11 | Mon = [0 for i in range(20)] #ให้ตัวแปร Mon มีค่าเริ่มต้นเป็น 0 ทั้งหมด
12 | Hoff = [0 for i in range(20)] #ให้ตัวแปร Hoff มีค่าเริ่มต้นเป็น 0 ทั้งหมด
13 | Moff = [0 for i in range(20)] #ให้ตัวแปร Hoff มีค่าเริ่มต้นเป็น 0 ทั้งหมด
14 |
15 | Pyserial = serial.Serial("COM5", 9600) #เปิดพอร์ตการสื่อสารอนุกรม
16 |
17 |
18 | #Method แสดงค่าเวลาปัจจุบัน
19 | def clock():
20 | currentTime = QTime.currentTime()
21 | currentTimeText = currentTime.toString('hh:mm:ss')
22 | ui.lcdDatetime.display(currentTimeText)
23 | global Hours,Mins,Sec
24 | Hours = currentTime.hour() #นำค่าเวลาที่เป็นชัวโมงเก็บไว้ในตัวแปร Hours
25 | Mins = currentTime.minute() #นำค่าเวลาที่เป็นนาทีไว้ในตัวแปร Mins
26 | Sec = currentTime.second() #นำค่าเวลาที่เป็นวินาทีเก็บไว้ในตัวแปร Sec
27 |
28 | def spnHon_click(value):
29 | Hon[0] = value
30 | print("Hour on set : " + str(Hon[0]))
31 |
32 | def spnMon_click(value):
33 | Mon[0] = value
34 | print("Min on set : " + str(Mon[0]))
35 |
36 | def spnHoff_click(value):
37 | Hoff[0] = value
38 | print("Hour off set : " + str(Hoff[0]))
39 |
40 | def spnMoff_click(value):
41 | Moff[0] = value
42 | print("Min off set : " + str(Moff[0]))
43 |
44 | def TimerProcess(): #Method การเช็คเวลา
45 | if Pyserial.isOpen(): #ตรวจสอบการเปิดพอร์ตอนุกรม
46 | if Hours == Hon[0] and Mins == Mon[0]: RelayCH1ON() #เงื่อนไขการสั่งเปิด
47 | elif Hours == Hoff[0] and Mins == Moff[0]: RelayCH1OFF() #เงื่อนไขการสั่งปิด
48 |
49 | def RelayCH1ON(): #Medthod การเปิดการทำงานรีเลย์ช่องที่ 1
50 | Pyserial.write(b'A') #หากมีการเรียกใช้งาน Method จะให้มีการส่ง 'A' ผ่านพอร์ตอนุกรม
51 | print("Relay 1 is on")
52 |
53 | def RelayCH1OFF(): #Medthod การปิดการทำงานรีเลย์ช่องที่ 1
54 | Pyserial.write(b'a') #หากมีการเรียกใช้งาน Method จะให้มีการส่ง 'a' ผ่านพอร์ตอนุกรม
55 | print("Relay 1 is off")
56 |
57 | timer = QTimer(); #ฟังก์ชันการทำงานของเวลา
58 | timer.timeout.connect(clock) #เรียกใช้งานฟังก์ชันเวลาโดยเรียกใข้งาน Method clcok
59 | timer.timeout.connect(TimerProcess) #เรียกใช้งานฟังก์ชันเวลาโดยเรียกใข้งาน Method TimerProcess
60 | timer.start() #เริ่มการทำงาน timer
61 |
62 | ui.spn_Hon.valueChanged.connect(spnHon_click) #เช็คการเกิด Event บน QT Design โดยหากเกิด Event ให้เรียกใช้งาน spn_Hon Click
63 | ui.spn_Mon.valueChanged.connect(spnMon_click) #เช็คการเกิด Event บน QT Design โดยหากเกิด Event ให้เรียกใช้งาน spn_Mon Click
64 | ui.spn_Hoff.valueChanged.connect(spnHoff_click) #เช็คการเกิด Event บน QT Design โดยหากเกิด Event ให้เรียกใช้งาน spn_Hoff Click
65 | ui.spn_Moff.valueChanged.connect(spnMoff_click) #เช็คการเกิด Event บน QT Design โดยหากเกิด Event ให้เรียกใช้งาน spn_Moff Click
66 |
67 | ui.show()
68 | app.exec()
69 |
--------------------------------------------------------------------------------
/Example 5 On-Off Relay Simulation/Pyduino_ControlRelay/Pyduino_ControlRelay.ino:
--------------------------------------------------------------------------------
1 | unsigned int SerialBuffer = 0;
2 | #define RY01_pin 3
3 | #define ON 0
4 | #define OFF 1
5 | void setup() {
6 | Serial.begin(9600);
7 | pinMode(RY01_pin, OUTPUT);
8 | digitalWrite(RY01_pin, OFF);
9 | }
10 |
11 | void loop() {
12 | if(Serial.available()){
13 | SerialBuffer = Serial.read();
14 | }
15 | switch(SerialBuffer){
16 | case 'A':
17 | digitalWrite(RY01_pin, ON);
18 | break;
19 | case 'a':
20 | digitalWrite(RY01_pin, OFF);
21 | break;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Proteus Simulator/PyduinoSim.pdsprj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/Proteus Simulator/PyduinoSim.pdsprj
--------------------------------------------------------------------------------
/Proteus Simulator/readme:
--------------------------------------------------------------------------------
1 | in this simulator using Proteus 8.10 you can open with lower version but not for upper version 8.10
2 |
--------------------------------------------------------------------------------
/Pyduino.ino/Pyduino.ino:
--------------------------------------------------------------------------------
1 | unsigned long previousMillis = 0;
2 | const long interval = 10;
3 | unsigned int SerialBuffer = 0;
4 | int TX_data[4];
5 | #define RY01_pin 3
6 | #define RY02_pin 4
7 | #define Temp1_pin A0
8 | #define Temp2_pin A1
9 | #define Soil1_pin A2
10 | #define Soil2_pin A3
11 | #define ON 0
12 | #define OFF 1
13 | void setup() {
14 | Serial.begin(9600);
15 | pinMode(RY01_pin, OUTPUT);
16 | pinMode(RY02_pin, OUTPUT);
17 | pinMode(Temp1_pin, INPUT);
18 | pinMode(Temp2_pin, INPUT);
19 | pinMode(Soil1_pin, INPUT);
20 | pinMode(Soil2_pin, INPUT);
21 | digitalWrite(RY01_pin, OFF);
22 | digitalWrite(RY02_pin, OFF);
23 | }
24 |
25 | void loop() {
26 | if(Serial.available()){
27 | SerialBuffer = Serial.read();
28 | }
29 | switch(SerialBuffer){
30 | case 'A':
31 | digitalWrite(RY01_pin, ON);
32 | break;
33 | case 'a':
34 | digitalWrite(RY01_pin, OFF);
35 | break;
36 | case 'B':
37 | digitalWrite(RY02_pin, ON);
38 | break;
39 | case 'b':
40 | digitalWrite(RY02_pin, OFF);
41 | break;
42 | }
43 |
44 | TX_data[0] = analogRead(Temp1_pin);
45 | TX_data[1] = analogRead(Temp2_pin);
46 | TX_data[2] = analogRead(Soil1_pin);
47 | TX_data[3] = analogRead(Soil2_pin);
48 |
49 | TX_data[0] = map(TX_data[0],0,1024,0,100);
50 | TX_data[1] = map(TX_data[1],0,1024,0,100);
51 | TX_data[2] = map(TX_data[2],0,1024,0,100);
52 | TX_data[3] = map(TX_data[3],0,1024,0,100);
53 |
54 | //Serial.println(String(Value[0])+","+String(Value[1])+","+String(Value[2])+","+String(Value[3]));
55 | unsigned long currentMillis = millis();
56 | if (currentMillis - previousMillis >= interval) {
57 | previousMillis = currentMillis;
58 | Serial.println(String(TX_data[0])+","+String(TX_data[1])+","+String(TX_data[2])+","+String(TX_data[3]));
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/PyduinoGUI/Icon/Pyduino_img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/PyduinoGUI/Icon/Pyduino_img.png
--------------------------------------------------------------------------------
/PyduinoGUI/Icon/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/PyduinoGUI/Icon/cancel.png
--------------------------------------------------------------------------------
/PyduinoGUI/Icon/facebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/PyduinoGUI/Icon/facebook.png
--------------------------------------------------------------------------------
/PyduinoGUI/Icon/leaf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/PyduinoGUI/Icon/leaf.png
--------------------------------------------------------------------------------
/PyduinoGUI/Pyduino.py:
--------------------------------------------------------------------------------
1 | from ctypes.wintypes import BOOLEAN
2 | from os import read
3 | from PyQt5 import QtWidgets, uic, QtGui
4 | from PyQt5 import QtCore
5 | #from PyQt5.uic.properties import QtGui
6 | import serial
7 | import serial.tools.list_ports
8 | import sys
9 | from PyQt5.QtCore import QTime, QTimer
10 |
11 |
12 | app = QtWidgets.QApplication([])
13 |
14 | #add icons
15 | icon = QtGui.QIcon()
16 | icon.addFile('icon/leaf.png', QtCore.QSize(16,16))
17 | ui = uic.loadUi("Pyduino.ui")
18 | ui.setWindowTitle("Pyduino")
19 | ui.setWindowIcon(QtGui.QIcon(icon))
20 |
21 | Pyserial = serial.Serial()
22 | ports = serial.tools.list_ports.comports()
23 | portList = []
24 | for port in ports:
25 | portList.append(port[0])
26 |
27 | #initial value before use
28 | Hon = []; Mon = []; Hoff = []; Moff = []
29 | Hon = [0 for i in range(20)]
30 | Mon = [0 for i in range(20)]
31 | Hoff = [0 for i in range(20)]
32 | Moff = [0 for i in range(20)]
33 | Data_buffer = []
34 | Data_buffer = [0 for i in range(5)]
35 |
36 | def openPort():
37 | Pyserial.port = ui.cb_comport.currentText()
38 | Pyserial.baudrate = 115200
39 | Pyserial.open()
40 | ui.btn_Connect.setEnabled(False)
41 | ui.btn_Disconnect.setEnabled(True)
42 | Level.start(1000)
43 | if Pyserial.isOpen():
44 | print("Open port with : " + str(ui.cb_comport.currentText()))
45 |
46 | def closePort():
47 | Pyserial.close()
48 | ui.btn_Connect.setEnabled(True)
49 | ui.btn_Disconnect.setEnabled(False)
50 |
51 | #Read data incomming form uart
52 | def rxBuffer():
53 | if Pyserial.isOpen():
54 | global Data_buffer
55 | Data = Pyserial.readline().strip().decode('utf-8')
56 | Data_buffer = Data.split(",")
57 |
58 | #Update Bar
59 | def updateBar():
60 | ui.Temp_1.setValue(int(Data_buffer[0]))
61 | ui.Temp_2.setValue(int(Data_buffer[1]))
62 | ui.SoilTemp1.setValue(int(Data_buffer[2]))
63 | ui.SoilTemp2.setValue(int(Data_buffer[3]))
64 |
65 | #Show current time on lcd display
66 | def clock():
67 | currentTime = QTime.currentTime()
68 | currentTimeText = currentTime.toString('hh:mm:ss')
69 | ui.lcdDatetime.display(currentTimeText)
70 | global Hours,Mins,Sec
71 | Hours = currentTime.hour()
72 | Mins = currentTime.minute()
73 | Sec = currentTime.second()
74 |
75 | ################# Start : Hour time on the value from spinBox #################
76 | def spinHon_t1(value): Hon[0] = value #you can use Hon[0] = ui.spnHon_t1.value()
77 | def spinHon_t2(value): Hon[1] = value
78 | def spinHon_t3(value): Hon[2] = value
79 | def spinHon_t4(value): Hon[3] = value
80 | def spinHon_t5(value): Hon[4] = value
81 | def spinHon_t6(value): Hon[5] = value
82 | def spinHon_t7(value): Hon[6] = value
83 | def spinHon_t8(value): Hon[7] = value
84 | def spinHon_t9(value): Hon[8] = value
85 | def spinHon_t10(value): Hon[9] = value
86 | def spinHon_t11(value): Hon[10] = value
87 | def spinHon_t12(value): Hon[11] = value
88 | def spinHon_t13(value): Hon[12] = value
89 | def spinHon_t14(value): Hon[13] = value
90 | def spinHon_t15(value): Hon[14] = value
91 | def spinHon_t16(value): Hon[15] = value
92 | def spinHon_t17(value): Hon[16] = value
93 | def spinHon_t18(value): Hon[17] = value
94 | def spinHon_t19(value): Hon[18] = value
95 | def spinHon_t20(value): Hon[19] = value
96 |
97 | ################# Start : Min time on the value from spinBox #################
98 | def spinMon_t1(value): Mon[0] = value
99 | def spinMon_t2(value): Mon[1] = value
100 | def spinMon_t3(value): Mon[2] = value
101 | def spinMon_t4(value): Mon[3] = value
102 | def spinMon_t5(value): Mon[4] = value
103 | def spinMon_t6(value): Mon[5] = value
104 | def spinMon_t7(value): Mon[6] = value
105 | def spinMon_t8(value): Mon[7] = value
106 | def spinMon_t9(value): Mon[8] = value
107 | def spinMon_t10(value): Mon[9] = value
108 | def spinMon_t11(value): Mon[10] = value
109 | def spinMon_t12(value): Mon[11] = value
110 | def spinMon_t13(value): Mon[12] = value
111 | def spinMon_t14(value): Mon[13] = value
112 | def spinMon_t15(value): Mon[14] = value
113 | def spinMon_t16(value): Mon[15] = value
114 | def spinMon_t17(value): Mon[16] = value
115 | def spinMon_t18(value): Mon[17] = value
116 | def spinMon_t19(value): Mon[18] = value
117 | def spinMon_t20(value): Mon[19] = value
118 |
119 | ################# Start : Hour time off the value from spinBox #################
120 | def spinHoff_t1(value): Hoff[0] = value #you can use Hon[0] = ui.spnHon_t1.value()
121 | def spinHoff_t2(value): Hoff[1] = value
122 | def spinHoff_t3(value): Hoff[2] = value
123 | def spinHoff_t4(value): Hoff[3] = value
124 | def spinHoff_t5(value): Hoff[4] = value
125 | def spinHoff_t6(value): Hoff[5] = value
126 | def spinHoff_t7(value): Hoff[6] = value
127 | def spinHoff_t8(value): Hoff[7] = value
128 | def spinHoff_t9(value): Hoff[8] = value
129 | def spinHoff_t10(value): Hoff[9] = value
130 | def spinHoff_t11(value): Hoff[10] = value
131 | def spinHoff_t12(value): Hoff[11] = value
132 | def spinHoff_t13(value): Hoff[12] = value
133 | def spinHoff_t14(value): Hoff[13] = value
134 | def spinHoff_t15(value): Hoff[14] = value
135 | def spinHoff_t16(value): Hoff[15] = value
136 | def spinHoff_t17(value): Hoff[16] = value
137 | def spinHoff_t18(value): Hoff[17] = value
138 | def spinHoff_t19(value): Hoff[18] = value
139 | def spinHoff_t20(value): Hoff[19] = value
140 |
141 |
142 | ################# Start : Min time off the value from spinBox #################
143 | def spinMoff_t1(value): Moff[0] = value
144 | def spinMoff_t2(value): Moff[1] = value
145 | def spinMoff_t3(value): Moff[2] = value
146 | def spinMoff_t4(value): Moff[3] = value
147 | def spinMoff_t5(value): Moff[4] = value
148 | def spinMoff_t6(value): Moff[5] = value
149 | def spinMoff_t7(value): Moff[6] = value
150 | def spinMoff_t8(value): Moff[7] = value
151 | def spinMoff_t9(value): Moff[8] = value
152 | def spinMoff_t10(value): Moff[9] = value
153 | def spinMoff_t11(value): Moff[10] = value
154 | def spinMoff_t12(value): Moff[11] = value
155 | def spinMoff_t13(value): Moff[12] = value
156 | def spinMoff_t14(value): Moff[13] = value
157 | def spinMoff_t15(value): Moff[14] = value
158 | def spinMoff_t16(value): Moff[15] = value
159 | def spinMoff_t17(value): Moff[16] = value
160 | def spinMoff_t18(value): Moff[17] = value
161 | def spinMoff_t19(value): Moff[18] = value
162 | def spinMoff_t20(value): Moff[19] = value
163 |
164 | def RelayCH1ON():
165 | Pyserial.write(b'A')
166 |
167 | def RelayCH1OFF():
168 | Pyserial.write(b'a')
169 |
170 | def RelayCH2ON():
171 | Pyserial.write(b'B')
172 |
173 | def RelayCH2OFF():
174 | Pyserial.write(b'b')
175 |
176 | def TimerProcess():
177 | if Pyserial.isOpen():
178 | if ui.ckb_t1.isChecked(): #Timer1 CH1
179 | if Hours == Hon[0] and Mins == Mon[0]: RelayCH1ON()
180 | elif Hours == Hoff[0] and Mins == Moff[0]: RelayCH1OFF()
181 | if ui.ckb_t2.isChecked(): #Timer2 CH1
182 | if Hours == Hon[1] and Mins == Mon[1]: RelayCH1ON()
183 | elif Hours == Hoff[1] and Mins == Moff[1]: RelayCH1OFF()
184 | if ui.ckb_t3.isChecked(): #Timer3 CH1
185 | if Hours == Hon[2] and Mins == Mon[2]: RelayCH1ON()
186 | elif Hours == Hoff[2] and Mins == Moff[2]: RelayCH1OFF()
187 | if ui.ckb_t4.isChecked(): #Timer4 CH1
188 | if Hours == Hon[3] and Mins == Mon[3]: RelayCH1ON()
189 | elif Hours == Hoff[3] and Mins == Moff[3]: RelayCH1OFF()
190 | if ui.ckb_t5.isChecked(): #Timer5 CH1
191 | if Hours == Hon[4] and Mins == Mon[4]: RelayCH1ON()
192 | elif Hours == Hoff[4] and Mins == Moff[4]: RelayCH1OFF()
193 | if ui.ckb_t6.isChecked(): #Timer6 CH1
194 | if Hours == Hon[5] and Mins == Mon[5]: RelayCH1ON()
195 | elif Hours == Hoff[5] and Mins == Moff[5]: RelayCH1OFF()
196 | if ui.ckb_t7.isChecked(): #Timer7 CH1
197 | if Hours == Hon[6] and Mins == Mon[6]: RelayCH1ON()
198 | elif Hours == Hoff[6] and Mins == Moff[6]: RelayCH1OFF()
199 | if ui.ckb_t8.isChecked(): #Timer8 CH1
200 | if Hours == Hon[7] and Mins == Mon[7]: RelayCH1ON()
201 | elif Hours == Hoff[7] and Mins == Moff[7]: RelayCH1OFF()
202 | if ui.ckb_t9.isChecked(): #Time9 CH1
203 | if Hours == Hon[8] and Mins == Mon[8]: RelayCH1ON()
204 | elif Hours == Hoff[8] and Mins == Moff[8]: RelayCH1OFF()
205 | if ui.ckb_t10.isChecked(): #Timer10 CH1
206 | if Hours == Hon[9] and Mins == Mon[9]: RelayCH1ON()
207 | elif Hours == Hoff[9] and Mins == Moff[9]: RelayCH1OFF()
208 |
209 | if ui.ckb_t11.isChecked(): #Timer1 CH2
210 | if Hours == Hon[10] and Mins == Mon[10]: RelayCH2ON()
211 | elif Hours == Hoff[10] and Mins == Moff[10]: RelayCH2OFF()
212 | if ui.ckb_t12.isChecked(): #Timer2 CH2
213 | if Hours == Hon[11] and Mins == Mon[11]: RelayCH2ON()
214 | elif Hours == Hoff[11] and Mins == Moff[11]: RelayCH2OFF()
215 | if ui.ckb_t13.isChecked(): #Timer3 CH2
216 | if Hours == Hon[12] and Mins == Mon[12]: RelayCH2ON()
217 | elif Hours == Hoff[12] and Mins == Moff[12]: RelayCH2OFF()
218 | if ui.ckb_t14.isChecked(): #Timer4 CH2
219 | if Hours == Hon[13] and Mins == Mon[13]: RelayCH2ON()
220 | elif Hours == Hoff[13] and Mins == Moff[13]: RelayCH2OFF()
221 | if ui.ckb_t15.isChecked(): #Timer5 CH2
222 | if Hours == Hon[14] and Mins == Mon[14]: RelayCH2ON()
223 | elif Hours == Hoff[14] and Mins == Moff[14]: RelayCH2OFF()
224 | if ui.ckb_t16.isChecked(): #Timer6 CH1
225 | if Hours == Hon[15] and Mins == Mon[15]: RelayCH2ON()
226 | elif Hours == Hoff[15] and Mins == Moff[15]: RelayCH2OFF()
227 | if ui.ckb_t17.isChecked(): #Timer7 CH2
228 | if Hours == Hon[16] and Mins == Mon[16]: RelayCH2ON()
229 | elif Hours == Hoff[16] and Mins == Moff[16]: RelayCH2OFF()
230 | if ui.ckb_t18.isChecked(): #Timer8 CH2
231 | if Hours == Hon[17] and Mins == Mon[17]: RelayCH2ON()
232 | elif Hours == Hoff[17] and Mins == Moff[17]: RelayCH2OFF()
233 | if ui.ckb_t19.isChecked(): #Timer9 CH2
234 | if Hours == Hon[18] and Mins == Mon[18]: RelayCH2ON()
235 | elif Hours == Hoff[18] and Mins == Moff[18]: RelayCH2OFF()
236 | if ui.ckb_t20.isChecked(): #Timer10 CH2
237 | if Hours == Hon[19] and Mins == Mon[19]: RelayCH2ON()
238 | elif Hours == Hoff[19] and Mins == Moff[19]: RelayCH2OFF()
239 |
240 |
241 | def CH01ON():
242 | Pyserial.write(b'A')
243 | print("RY01 is ON")
244 | def CH01OFF():
245 | Pyserial.write(b'a')
246 | print("RY01 is OFF")
247 | def CH02ON():
248 | Pyserial.write(b'B')
249 | print("RY02 is ON")
250 | def CH02OFF():
251 | Pyserial.write(b'b')
252 | print("RY02 is OFF")
253 |
254 | timer = QTimer();
255 | timer.timeout.connect(clock)
256 | timer.timeout.connect(TimerProcess)
257 | timer.start()
258 |
259 | # update current data from uart to progress bar
260 | Level = QTimer()
261 | Level.timeout.connect(updateBar)
262 |
263 | readRx = QTimer()
264 | readRx.timeout.connect(rxBuffer)
265 | readRx.start(1)
266 |
267 |
268 |
269 | def closeApp():
270 | sys.exit()
271 | #################################### spinBox Hours on ####################################
272 | ui.spnHon_t1.valueChanged.connect(spinHon_t1)
273 | ui.spnHon_t2.valueChanged.connect(spinHon_t2)
274 | ui.spnHon_t3.valueChanged.connect(spinHon_t3)
275 | ui.spnHon_t4.valueChanged.connect(spinHon_t4)
276 | ui.spnHon_t5.valueChanged.connect(spinHon_t5)
277 | ui.spnHon_t6.valueChanged.connect(spinHon_t6)
278 | ui.spnHon_t7.valueChanged.connect(spinHon_t7)
279 | ui.spnHon_t8.valueChanged.connect(spinHon_t8)
280 | ui.spnHon_t9.valueChanged.connect(spinHon_t9)
281 | ui.spnHon_t10.valueChanged.connect(spinHon_t10)
282 | ui.spnHon_t11.valueChanged.connect(spinHon_t11)
283 | ui.spnHon_t12.valueChanged.connect(spinHon_t12)
284 | ui.spnHon_t13.valueChanged.connect(spinHon_t13)
285 | ui.spnHon_t14.valueChanged.connect(spinHon_t14)
286 | ui.spnHon_t15.valueChanged.connect(spinHon_t15)
287 | ui.spnHon_t16.valueChanged.connect(spinHon_t16)
288 | ui.spnHon_t17.valueChanged.connect(spinHon_t17)
289 | ui.spnHon_t18.valueChanged.connect(spinHon_t18)
290 | ui.spnHon_t19.valueChanged.connect(spinHon_t19)
291 | ui.spnHon_t20.valueChanged.connect(spinHon_t20)
292 | #################################### spinBox Min on ####################################
293 | ui.spnMon_t1.valueChanged.connect(spinMon_t1)
294 | ui.spnMon_t2.valueChanged.connect(spinMon_t2)
295 | ui.spnMon_t3.valueChanged.connect(spinMon_t3)
296 | ui.spnMon_t4.valueChanged.connect(spinMon_t4)
297 | ui.spnMon_t5.valueChanged.connect(spinMon_t5)
298 | ui.spnMon_t6.valueChanged.connect(spinMon_t6)
299 | ui.spnMon_t7.valueChanged.connect(spinMon_t7)
300 | ui.spnMon_t8.valueChanged.connect(spinMon_t8)
301 | ui.spnMon_t9.valueChanged.connect(spinMon_t9)
302 | ui.spnMon_t10.valueChanged.connect(spinMon_t10)
303 | ui.spnMon_t11.valueChanged.connect(spinMon_t11)
304 | ui.spnMon_t12.valueChanged.connect(spinMon_t12)
305 | ui.spnMon_t13.valueChanged.connect(spinMon_t13)
306 | ui.spnMon_t14.valueChanged.connect(spinMon_t14)
307 | ui.spnMon_t15.valueChanged.connect(spinMon_t15)
308 | ui.spnMon_t16.valueChanged.connect(spinMon_t16)
309 | ui.spnMon_t17.valueChanged.connect(spinMon_t17)
310 | ui.spnMon_t18.valueChanged.connect(spinMon_t18)
311 | ui.spnMon_t19.valueChanged.connect(spinMon_t19)
312 | ui.spnMon_t20.valueChanged.connect(spinMon_t20)
313 |
314 | #################################### spinBox Hours off ####################################
315 | ui.spnHoff_t1.valueChanged.connect(spinHoff_t1)
316 | ui.spnHoff_t5.valueChanged.connect(spinHoff_t5)
317 | ui.spnHoff_t4.valueChanged.connect(spinHoff_t4)
318 | ui.spnHoff_t2.valueChanged.connect(spinHoff_t2)
319 | ui.spnHoff_t6.valueChanged.connect(spinHoff_t6)
320 | ui.spnHoff_t3.valueChanged.connect(spinHoff_t3)
321 | ui.spnHoff_t7.valueChanged.connect(spinHoff_t7)
322 | ui.spnHoff_t8.valueChanged.connect(spinHoff_t8)
323 | ui.spnHoff_t9.valueChanged.connect(spinHoff_t9)
324 | ui.spnHoff_t11.valueChanged.connect(spinHoff_t11)
325 | ui.spnHoff_t10.valueChanged.connect(spinHoff_t10)
326 | ui.spnHoff_t12.valueChanged.connect(spinHoff_t12)
327 | ui.spnHoff_t13.valueChanged.connect(spinHoff_t13)
328 | ui.spnHoff_t14.valueChanged.connect(spinHoff_t14)
329 | ui.spnHoff_t15.valueChanged.connect(spinHoff_t15)
330 | ui.spnHoff_t16.valueChanged.connect(spinHoff_t16)
331 | ui.spnHoff_t17.valueChanged.connect(spinHoff_t17)
332 | ui.spnHoff_t18.valueChanged.connect(spinHoff_t18)
333 | ui.spnHoff_t19.valueChanged.connect(spinHoff_t19)
334 | ui.spnHoff_t20.valueChanged.connect(spinHoff_t20)
335 | #################################### spinBox Min off ####################################
336 | ui.spnMoff_t1.valueChanged.connect(spinMoff_t1)
337 | ui.spnMoff_t2.valueChanged.connect(spinMoff_t2)
338 | ui.spnMoff_t3.valueChanged.connect(spinMoff_t3)
339 | ui.spnMoff_t4.valueChanged.connect(spinMoff_t4)
340 | ui.spnMoff_t5.valueChanged.connect(spinMoff_t5)
341 | ui.spnMoff_t6.valueChanged.connect(spinMoff_t6)
342 | ui.spnMoff_t7.valueChanged.connect(spinMoff_t7)
343 | ui.spnMoff_t8.valueChanged.connect(spinMoff_t8)
344 | ui.spnMoff_t9.valueChanged.connect(spinMoff_t9)
345 | ui.spnMoff_t10.valueChanged.connect(spinMoff_t10)
346 | ui.spnMoff_t11.valueChanged.connect(spinMoff_t11)
347 | ui.spnMoff_t12.valueChanged.connect(spinMoff_t12)
348 | ui.spnMoff_t13.valueChanged.connect(spinMoff_t13)
349 | ui.spnMoff_t14.valueChanged.connect(spinMoff_t14)
350 | ui.spnMoff_t15.valueChanged.connect(spinMoff_t15)
351 | ui.spnMoff_t16.valueChanged.connect(spinMoff_t16)
352 | ui.spnMoff_t17.valueChanged.connect(spinMoff_t17)
353 | ui.spnMoff_t18.valueChanged.connect(spinMoff_t18)
354 | ui.spnMoff_t19.valueChanged.connect(spinMoff_t19)
355 | ui.spnMoff_t20.valueChanged.connect(spinMoff_t20)
356 |
357 |
358 | ui.RY01ON.clicked.connect(CH01ON)
359 | ui.RY01OFF.clicked.connect(CH01OFF)
360 | ui.RY02ON.clicked.connect(CH02ON)
361 | ui.RY02OFF.clicked.connect(CH02OFF)
362 |
363 | ui.cb_comport.addItems(portList)
364 | ui.btn_close.clicked.connect(closeApp)
365 | ui.btn_Connect.clicked.connect(openPort)
366 | ui.btn_Disconnect.clicked.connect(closePort)
367 |
368 | ui.show()
369 | app.exec()
370 |
371 |
372 |
--------------------------------------------------------------------------------
/PyduinoGUI/Pyduino.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | MainWindow
4 |
5 |
6 |
7 | 0
8 | 0
9 | 730
10 | 459
11 |
12 |
13 |
14 | MainWindow
15 |
16 |
17 |
18 |
19 |
20 | false
21 |
22 |
23 | QTabWidget::Rounded
24 |
25 |
26 |
27 |
28 |
29 | 0
30 | 0
31 | 221
32 | 461
33 |
34 |
35 |
36 | background-color: rgb(255, 170, 255);
37 |
38 |
39 |
40 |
41 |
42 | false
43 |
44 |
45 |
46 |
47 | 10
48 | 185
49 | 111
50 | 22
51 |
52 |
53 |
54 | background-color: rgb(255, 255, 255);
55 |
56 |
57 |
58 |
59 |
60 | 130
61 | 185
62 | 75
63 | 23
64 |
65 |
66 |
67 | background-color: rgb(255, 255, 255);
68 |
69 |
70 | Connect
71 |
72 |
73 |
74 |
75 |
76 | 130
77 | 210
78 | 75
79 | 23
80 |
81 |
82 |
83 | background-color: rgb(255, 255, 255);
84 |
85 |
86 | Disconnect
87 |
88 |
89 |
90 |
91 |
92 | 10
93 | 40
94 | 181
95 | 131
96 |
97 |
98 |
99 |
100 |
101 |
102 | Icon/Pyduino_img.png
103 |
104 |
105 | true
106 |
107 |
108 |
109 |
110 |
111 | 30
112 | 20
113 | 161
114 | 31
115 |
116 |
117 |
118 |
119 | FC Muffin
120 | 28
121 |
122 |
123 |
124 | QFrame::Plain
125 |
126 |
127 | Pyduino Serial
128 |
129 |
130 | Qt::AutoText
131 |
132 |
133 | false
134 |
135 |
136 |
137 |
138 |
139 | 10
140 | 300
141 | 201
142 | 71
143 |
144 |
145 |
146 |
147 | FC Home
148 | 5
149 | 50
150 | true
151 | false
152 | false
153 |
154 |
155 |
156 |
157 | color: rgb(170, 255, 0);
158 | background-color: rgb(255, 255, 255);
159 |
160 |
161 | QFrame::NoFrame
162 |
163 |
164 | 1
165 |
166 |
167 | true
168 |
169 |
170 | 8
171 |
172 |
173 | QLCDNumber::Flat
174 |
175 |
176 | 0.000000000000000
177 |
178 |
179 | 0
180 |
181 |
182 |
183 |
184 |
185 | 124
186 | 410
187 | 71
188 | 41
189 |
190 |
191 |
192 |
193 | FC Home
194 | 13
195 |
196 |
197 |
198 | background-color: rgb(255, 255, 255);
199 |
200 |
201 | Close
202 |
203 |
204 |
205 | Icon/cancel.pngIcon/cancel.png
206 |
207 |
208 | false
209 |
210 |
211 | btn_Connect
212 | cb_comport
213 | btn_Disconnect
214 | label
215 | label_2
216 | lcdDatetime
217 | btn_close
218 |
219 |
220 |
221 |
222 | 220
223 | 0
224 | 511
225 | 461
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 | 10
235 | 80
236 | 251
237 | 371
238 |
239 |
240 |
241 | CH 1
242 |
243 |
244 |
245 |
246 | 10
247 | 90
248 | 22
249 | 271
250 |
251 |
252 |
253 |
254 | 10
255 |
256 |
257 | 0
258 |
259 |
260 | 0
261 |
262 |
263 | 0
264 |
265 |
266 | 0
267 |
268 | -
269 |
270 |
271 |
272 |
273 |
274 |
275 | -
276 |
277 |
278 |
279 |
280 |
281 |
282 | -
283 |
284 |
285 |
286 |
287 |
288 |
289 | -
290 |
291 |
292 |
293 |
294 |
295 |
296 | -
297 |
298 |
299 |
300 |
301 |
302 |
303 | -
304 |
305 |
306 |
307 |
308 |
309 |
310 | -
311 |
312 |
313 |
314 |
315 |
316 |
317 | -
318 |
319 |
320 |
321 |
322 |
323 |
324 | -
325 |
326 |
327 |
328 |
329 |
330 |
331 | -
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 | 30
344 | 90
345 | 211
346 | 271
347 |
348 |
349 |
350 | -
351 |
352 |
353 | Qt::AlignCenter
354 |
355 |
356 | 23
357 |
358 |
359 |
360 | -
361 |
362 |
363 | Qt::AlignCenter
364 |
365 |
366 | 23
367 |
368 |
369 |
370 | -
371 |
372 |
373 | Qt::AlignCenter
374 |
375 |
376 | 23
377 |
378 |
379 |
380 | -
381 |
382 |
383 | false
384 |
385 |
386 | true
387 |
388 |
389 | Qt::AlignCenter
390 |
391 |
392 | 23
393 |
394 |
395 |
396 | -
397 |
398 |
399 | Qt::AlignCenter
400 |
401 |
402 | 23
403 |
404 |
405 |
406 | -
407 |
408 |
409 | Qt::AlignCenter
410 |
411 |
412 | 23
413 |
414 |
415 |
416 | -
417 |
418 |
419 | Qt::AlignCenter
420 |
421 |
422 | 23
423 |
424 |
425 |
426 | -
427 |
428 |
429 | Qt::AlignCenter
430 |
431 |
432 | 23
433 |
434 |
435 |
436 | -
437 |
438 |
439 | Qt::AlignCenter
440 |
441 |
442 | 23
443 |
444 |
445 |
446 | -
447 |
448 |
449 | Qt::AlignCenter
450 |
451 |
452 | 59
453 |
454 |
455 |
456 | -
457 |
458 |
459 | Qt::AlignCenter
460 |
461 |
462 | 59
463 |
464 |
465 |
466 | -
467 |
468 |
469 | Qt::AlignCenter
470 |
471 |
472 | 59
473 |
474 |
475 |
476 | -
477 |
478 |
479 | Qt::AlignCenter
480 |
481 |
482 | 59
483 |
484 |
485 |
486 | -
487 |
488 |
489 | Qt::AlignCenter
490 |
491 |
492 | 23
493 |
494 |
495 |
496 | -
497 |
498 |
499 | Qt::AlignCenter
500 |
501 |
502 | 59
503 |
504 |
505 |
506 | -
507 |
508 |
509 | Qt::AlignCenter
510 |
511 |
512 | 59
513 |
514 |
515 |
516 | -
517 |
518 |
519 | Qt::AlignCenter
520 |
521 |
522 | 59
523 |
524 |
525 |
526 | -
527 |
528 |
529 | Qt::AlignCenter
530 |
531 |
532 | 59
533 |
534 |
535 |
536 | -
537 |
538 |
539 | Qt::AlignCenter
540 |
541 |
542 | 59
543 |
544 |
545 |
546 | -
547 |
548 |
549 | Qt::AlignCenter
550 |
551 |
552 | 59
553 |
554 |
555 |
556 | -
557 |
558 |
559 | 59
560 |
561 |
562 |
563 | -
564 |
565 |
566 | 23
567 |
568 |
569 |
570 | -
571 |
572 |
573 | Qt::Horizontal
574 |
575 |
576 |
577 | 40
578 | 20
579 |
580 |
581 |
582 |
583 | -
584 |
585 |
586 | 23
587 |
588 |
589 |
590 | -
591 |
592 |
593 | 23
594 |
595 |
596 |
597 | -
598 |
599 |
600 | 23
601 |
602 |
603 |
604 | -
605 |
606 |
607 | 23
608 |
609 |
610 |
611 | -
612 |
613 |
614 | 23
615 |
616 |
617 |
618 | -
619 |
620 |
621 | 23
622 |
623 |
624 |
625 | -
626 |
627 |
628 | 23
629 |
630 |
631 |
632 | -
633 |
634 |
635 | 23
636 |
637 |
638 |
639 | -
640 |
641 |
642 | 23
643 |
644 |
645 |
646 | -
647 |
648 |
649 | 59
650 |
651 |
652 |
653 | -
654 |
655 |
656 | 59
657 |
658 |
659 |
660 | -
661 |
662 |
663 | 59
664 |
665 |
666 |
667 | -
668 |
669 |
670 | 59
671 |
672 |
673 |
674 | -
675 |
676 |
677 | 59
678 |
679 |
680 |
681 | -
682 |
683 |
684 | 59
685 |
686 |
687 |
688 | -
689 |
690 |
691 | 59
692 |
693 |
694 |
695 | -
696 |
697 |
698 | 59
699 |
700 |
701 |
702 | -
703 |
704 |
705 | 59
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 | 50
715 | 20
716 | 75
717 | 23
718 |
719 |
720 |
721 | color: rgb(85, 170, 0);
722 |
723 |
724 | ON
725 |
726 |
727 |
728 |
729 |
730 | 140
731 | 20
732 | 75
733 | 23
734 |
735 |
736 |
737 | color: rgb(0, 0, 0);
738 | color: rgb(255, 0, 0);
739 |
740 |
741 | OFF
742 |
743 |
744 |
745 |
746 |
747 | 160
748 | 65
749 | 81
750 | 31
751 |
752 |
753 |
754 |
755 | FC Home
756 | 10
757 |
758 |
759 |
760 | ชั่วโมง นาที
761 |
762 |
763 | Qt::AlignCenter
764 |
765 |
766 |
767 |
768 |
769 | 30
770 | 65
771 | 81
772 | 31
773 |
774 |
775 |
776 |
777 | FC Home
778 | 10
779 |
780 |
781 |
782 | ชั่วโมง นาที
783 |
784 |
785 | Qt::AlignCenter
786 |
787 |
788 |
789 |
790 |
791 | 160
792 | 50
793 | 81
794 | 31
795 |
796 |
797 |
798 |
799 | FC Home
800 | 15
801 |
802 |
803 |
804 | ปิด
805 |
806 |
807 | Qt::AlignCenter
808 |
809 |
810 |
811 |
812 |
813 | 40
814 | 50
815 | 71
816 | 31
817 |
818 |
819 |
820 |
821 | FC Home
822 | 15
823 |
824 |
825 |
826 | Qt::ImhNone
827 |
828 |
829 | QFrame::Plain
830 |
831 |
832 | เปิด
833 |
834 |
835 | false
836 |
837 |
838 | Qt::AlignCenter
839 |
840 |
841 |
842 |
843 |
844 |
845 | 260
846 | 80
847 | 251
848 | 371
849 |
850 |
851 |
852 | CH 2
853 |
854 |
855 |
856 |
857 | 10
858 | 90
859 | 22
860 | 271
861 |
862 |
863 |
864 |
865 | 10
866 |
867 |
868 | 0
869 |
870 |
871 | 0
872 |
873 |
874 | 0
875 |
876 |
877 | 0
878 |
879 | -
880 |
881 |
882 |
883 |
884 |
885 |
886 | -
887 |
888 |
889 |
890 |
891 |
892 |
893 | -
894 |
895 |
896 |
897 |
898 |
899 |
900 | -
901 |
902 |
903 |
904 |
905 |
906 |
907 | -
908 |
909 |
910 |
911 |
912 |
913 |
914 | -
915 |
916 |
917 |
918 |
919 |
920 |
921 | -
922 |
923 |
924 |
925 |
926 |
927 |
928 | -
929 |
930 |
931 |
932 |
933 |
934 |
935 | -
936 |
937 |
938 |
939 |
940 |
941 |
942 | -
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 | 40
955 | 50
956 | 71
957 | 31
958 |
959 |
960 |
961 |
962 | FC Home
963 | 15
964 |
965 |
966 |
967 | Qt::ImhNone
968 |
969 |
970 | QFrame::Plain
971 |
972 |
973 | เปิด
974 |
975 |
976 | false
977 |
978 |
979 | Qt::AlignCenter
980 |
981 |
982 |
983 |
984 |
985 | 160
986 | 50
987 | 81
988 | 31
989 |
990 |
991 |
992 |
993 | FC Home
994 | 15
995 |
996 |
997 |
998 | ปิด
999 |
1000 |
1001 | Qt::AlignCenter
1002 |
1003 |
1004 |
1005 |
1006 |
1007 | 30
1008 | 90
1009 | 211
1010 | 271
1011 |
1012 |
1013 |
1014 | -
1015 |
1016 |
1017 | 59
1018 |
1019 |
1020 |
1021 | -
1022 |
1023 |
1024 | Qt::AlignCenter
1025 |
1026 |
1027 | 23
1028 |
1029 |
1030 |
1031 | -
1032 |
1033 |
1034 | Qt::AlignCenter
1035 |
1036 |
1037 | 23
1038 |
1039 |
1040 |
1041 | -
1042 |
1043 |
1044 | Qt::AlignCenter
1045 |
1046 |
1047 | 23
1048 |
1049 |
1050 |
1051 | -
1052 |
1053 |
1054 | Qt::AlignCenter
1055 |
1056 |
1057 | 23
1058 |
1059 |
1060 |
1061 | -
1062 |
1063 |
1064 | Qt::AlignCenter
1065 |
1066 |
1067 | 23
1068 |
1069 |
1070 |
1071 | -
1072 |
1073 |
1074 | Qt::AlignCenter
1075 |
1076 |
1077 | 23
1078 |
1079 |
1080 |
1081 | -
1082 |
1083 |
1084 | Qt::AlignCenter
1085 |
1086 |
1087 | 23
1088 |
1089 |
1090 |
1091 | -
1092 |
1093 |
1094 | Qt::AlignCenter
1095 |
1096 |
1097 | 23
1098 |
1099 |
1100 |
1101 | -
1102 |
1103 |
1104 | Qt::AlignCenter
1105 |
1106 |
1107 | 23
1108 |
1109 |
1110 |
1111 | -
1112 |
1113 |
1114 | Qt::AlignCenter
1115 |
1116 |
1117 | 23
1118 |
1119 |
1120 |
1121 | -
1122 |
1123 |
1124 | 59
1125 |
1126 |
1127 |
1128 | -
1129 |
1130 |
1131 | 59
1132 |
1133 |
1134 |
1135 | -
1136 |
1137 |
1138 | 59
1139 |
1140 |
1141 |
1142 | -
1143 |
1144 |
1145 | 59
1146 |
1147 |
1148 |
1149 | -
1150 |
1151 |
1152 | 59
1153 |
1154 |
1155 |
1156 | -
1157 |
1158 |
1159 | 59
1160 |
1161 |
1162 |
1163 | -
1164 |
1165 |
1166 | 59
1167 |
1168 |
1169 |
1170 | -
1171 |
1172 |
1173 | 59
1174 |
1175 |
1176 |
1177 | -
1178 |
1179 |
1180 | 59
1181 |
1182 |
1183 |
1184 | -
1185 |
1186 |
1187 | Qt::Horizontal
1188 |
1189 |
1190 |
1191 | 40
1192 | 20
1193 |
1194 |
1195 |
1196 |
1197 | -
1198 |
1199 |
1200 | 23
1201 |
1202 |
1203 |
1204 | -
1205 |
1206 |
1207 | 59
1208 |
1209 |
1210 |
1211 | -
1212 |
1213 |
1214 | 23
1215 |
1216 |
1217 |
1218 | -
1219 |
1220 |
1221 | 23
1222 |
1223 |
1224 |
1225 | -
1226 |
1227 |
1228 | 23
1229 |
1230 |
1231 |
1232 | -
1233 |
1234 |
1235 | 23
1236 |
1237 |
1238 |
1239 | -
1240 |
1241 |
1242 | 23
1243 |
1244 |
1245 |
1246 | -
1247 |
1248 |
1249 | 23
1250 |
1251 |
1252 |
1253 | -
1254 |
1255 |
1256 | 23
1257 |
1258 |
1259 |
1260 | -
1261 |
1262 |
1263 | 23
1264 |
1265 |
1266 |
1267 | -
1268 |
1269 |
1270 | 23
1271 |
1272 |
1273 |
1274 | -
1275 |
1276 |
1277 | 59
1278 |
1279 |
1280 |
1281 | -
1282 |
1283 |
1284 | 59
1285 |
1286 |
1287 |
1288 | -
1289 |
1290 |
1291 | 59
1292 |
1293 |
1294 |
1295 | -
1296 |
1297 |
1298 | 59
1299 |
1300 |
1301 |
1302 | -
1303 |
1304 |
1305 | 59
1306 |
1307 |
1308 |
1309 | -
1310 |
1311 |
1312 | 59
1313 |
1314 |
1315 |
1316 | -
1317 |
1318 |
1319 | 59
1320 |
1321 |
1322 |
1323 | -
1324 |
1325 |
1326 | 59
1327 |
1328 |
1329 |
1330 | -
1331 |
1332 |
1333 | 59
1334 |
1335 |
1336 |
1337 |
1338 |
1339 |
1340 |
1341 |
1342 | 40
1343 | 20
1344 | 75
1345 | 23
1346 |
1347 |
1348 |
1349 | color: rgb(255, 0, 127);
1350 | color: rgb(85, 170, 0);
1351 |
1352 |
1353 | ON
1354 |
1355 |
1356 |
1357 |
1358 |
1359 | 130
1360 | 20
1361 | 75
1362 | 23
1363 |
1364 |
1365 |
1366 | color: rgb(255, 0, 0);
1367 |
1368 |
1369 | OFF
1370 |
1371 |
1372 |
1373 |
1374 |
1375 | 160
1376 | 65
1377 | 81
1378 | 31
1379 |
1380 |
1381 |
1382 |
1383 | FC Home
1384 | 10
1385 |
1386 |
1387 |
1388 | ชั่วโมง นาที
1389 |
1390 |
1391 | Qt::AlignCenter
1392 |
1393 |
1394 |
1395 |
1396 |
1397 | 30
1398 | 65
1399 | 81
1400 | 31
1401 |
1402 |
1403 |
1404 |
1405 | FC Home
1406 | 10
1407 |
1408 |
1409 |
1410 | ชั่วโมง นาที
1411 |
1412 |
1413 | Qt::AlignCenter
1414 |
1415 |
1416 |
1417 |
1418 |
1419 |
1420 | 10
1421 | 10
1422 | 491
1423 | 61
1424 |
1425 |
1426 |
1427 | -
1428 |
1429 |
1430 | 50
1431 |
1432 |
1433 |
1434 | -
1435 |
1436 |
1437 |
1438 |
1439 |
1440 | 50
1441 |
1442 |
1443 | false
1444 |
1445 |
1446 |
1447 | -
1448 |
1449 |
1450 | 50
1451 |
1452 |
1453 |
1454 | -
1455 |
1456 |
1457 | 50
1458 |
1459 |
1460 |
1461 | -
1462 |
1463 |
1464 | Soil Moisture 2
1465 |
1466 |
1467 |
1468 | -
1469 |
1470 |
1471 | Soil Moisture 1
1472 |
1473 |
1474 |
1475 | -
1476 |
1477 |
1478 | Temperature 2
1479 |
1480 |
1481 |
1482 | -
1483 |
1484 |
1485 | Temperature 1
1486 |
1487 |
1488 |
1489 | -
1490 |
1491 |
1492 | Qt::Vertical
1493 |
1494 |
1495 |
1496 | 20
1497 | 40
1498 |
1499 |
1500 |
1501 |
1502 |
1503 |
1504 |
1505 |
1506 |
1507 |
1508 |
1509 |
1510 |
--------------------------------------------------------------------------------
/PyduinoGUI/__pycache__/testThead.cpython-39.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Phatthawat/PyQt5/d0093fc17406338418b134c17f4e07713363deb1/PyduinoGUI/__pycache__/testThead.cpython-39.pyc
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PyQt5
--------------------------------------------------------------------------------