SunFounder TS-10 10.1-inch Touch Screen
Code Explanation
RELAY_PIN
=
18
Relay connected to GPIO18 of the T-expansion board.
GPIO
.
setmode(GPIO
.
BCM)
GPIO
.
setup(RELAY_PIN, GPIO
.
OUT)
Set to BCM nomenclature and set
RELAY_PIN
to output.
def
relay_control
(value
=
None
):
GPIO
.
output(RELAY_PIN, value)
return
GPIO
.
input(RELAY_PIN)
This function controls the relay according to the
value
and returns the current level of the relay.
Note:
Since the relay works at high level, the relay closes when the switch state is True and opens when the switch
state is False.
variables
=
{
'LED On'
: {
'type'
:
'bool'
,
'value'
:
False
,
'bind'
: relay_control
},
}
By setting the value of the
'value'
key, we can set the initial value of the Switch widget, then always read
the value of the
'value'
key and send the current level of
RELAY_PIN
(the value returned by the function
relay_control()
) to Cloud4RPi.
Smart Light
In this project, we will learn to control the brightness of LED with Cloud4RPi’s Silder widget.
Experimental Procedures
Build the circuit.
5.5. Cloud4RPi
91
Содержание TS-10
Страница 1: ...SunFounder TS 10 10 1 inch Touch Screen www sunfounder com Nov 19 2021 ...
Страница 2: ......
Страница 6: ...SunFounder TS 10 10 1 inch Touch Screen 2 CONTENTS ...
Страница 9: ...SunFounder TS 10 10 1 inch Touch Screen 5 ...
Страница 10: ...SunFounder TS 10 10 1 inch Touch Screen 6 Chapter 1 HARDWARE DESCRIPTION ...
Страница 16: ...SunFounder TS 10 10 1 inch Touch Screen 12 Chapter 2 INSTALL THE RASPBERRY PI OS ...
Страница 21: ...SunFounder TS 10 10 1 inch Touch Screen pi 3 Step 5 17 ...
Страница 53: ...SunFounder TS 10 10 1 inch Touch Screen Now you have entered OctoPrint 5 3 3D Printer Monitor 49 ...
Страница 123: ...SunFounder TS 10 10 1 inch Touch Screen Also let it appear at the right time 5 7 Scratch Projects 119 ...
Страница 130: ...SunFounder TS 10 10 1 inch Touch Screen Set the balloon to a random position 126 Chapter 5 PROJECTS AND ACTIVITIES ...
Страница 131: ...SunFounder TS 10 10 1 inch Touch Screen Let it change the color and size randomly 5 7 Scratch Projects 127 ...
Страница 141: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 137 ...
Страница 160: ...SunFounder TS 10 10 1 inch Touch Screen Copy out the second Trees 156 Chapter 5 PROJECTS AND ACTIVITIES ...
Страница 165: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 161 ...
Страница 167: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 163 ...
Страница 171: ...SunFounder TS 10 10 1 inch Touch Screen Then we add the Pen extension function 5 7 Scratch Projects 167 ...
Страница 181: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 177 ...
Страница 209: ...SunFounder TS 10 10 1 inch Touch Screen 205 ...
Страница 210: ...SunFounder TS 10 10 1 inch Touch Screen 206 Chapter 7 3D PRINTED SUPPORT ...
Страница 212: ...SunFounder TS 10 10 1 inch Touch Screen 208 Chapter 8 FAQ ...