![background image](http://html.mh-extra.com/html/sunfounder/ts-10/ts-10_manual_1396383095.webp)
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
Summary of Contents for TS-10
Page 1: ...SunFounder TS 10 10 1 inch Touch Screen www sunfounder com Nov 19 2021 ...
Page 2: ......
Page 6: ...SunFounder TS 10 10 1 inch Touch Screen 2 CONTENTS ...
Page 9: ...SunFounder TS 10 10 1 inch Touch Screen 5 ...
Page 10: ...SunFounder TS 10 10 1 inch Touch Screen 6 Chapter 1 HARDWARE DESCRIPTION ...
Page 16: ...SunFounder TS 10 10 1 inch Touch Screen 12 Chapter 2 INSTALL THE RASPBERRY PI OS ...
Page 21: ...SunFounder TS 10 10 1 inch Touch Screen pi 3 Step 5 17 ...
Page 141: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 137 ...
Page 165: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 161 ...
Page 167: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 163 ...
Page 181: ...SunFounder TS 10 10 1 inch Touch Screen 5 7 Scratch Projects 177 ...
Page 209: ...SunFounder TS 10 10 1 inch Touch Screen 205 ...
Page 210: ...SunFounder TS 10 10 1 inch Touch Screen 206 Chapter 7 3D PRINTED SUPPORT ...
Page 212: ...SunFounder TS 10 10 1 inch Touch Screen 208 Chapter 8 FAQ ...