SunFounder TS-10 10.1-inch Touch Screen
Once added, you can use the Switch widget to control the LED; the value of the photoresistor on the Text widget will
be updated every 1 minute, when the value > 100, the motor rotates clockwise for 5 seconds; if the value is less than
20, the motor rotates counterclockwise for 5 seconds. You can see the change over time in the Chart widget.
Code Explanation
def
getValue
():
analogVal
=
ADC0834
.
getResult()
if
analogVal
>
100
:
move
.
clockwise()
sleep(
5
)
move
.
stop()
elif
analogVal
<
20
:
move
.
contrarotate()
sleep(
5
)
move
.
stop()
return
analogVal
Read the value of channel CH0 (with photoresistor connected) of the ADC0834. If the value is >100, the motor rotates
clockwise for 5 seconds. If the value is less than 20, the motor rotates counterclockwise for 5 seconds.
'CPU Temp'
: {
'type'
:
'numeric'
,
(continues on next page)
96
Chapter 5. PROJECTS AND ACTIVITIES
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 ...