SunFounder TS-10 10.1-inch Touch Screen
Code Explanation
led_val
=
GPIO
.
PWM(LED_PIN,
2000
)
led_val
.
start(
0
)
Call the
GPIO.PWM()
function to define
LED_PIN
as PWM pin and set the frequency of PWM pin to 2000Hz, then
use the
start()
function to set the initial duty cycle to 0.
led_val
.
ChangeDutyCycle(value)
The value sent by Slider widget to Raspberry Pi is used as PWM duty cycle to change the brightness of the LED.
variables
=
{
'CPU Temp'
: {
'type'
:
'numeric'
,
'value'
:
0
,
'bind'
: led_control
},
}
By setting the value of the
'value'
key, we can set the initial value of the Slider widget, then always read the value
of the
'value'
key and send the current level of
LED_PIN
(the value returned by the function
led_control
) to
Cloud4RPi.
Smart Curtain
In this project, we will simulate a scenario where the curtains are automatically opened or closed according to the
brightness of the room. When the photoresistor detects that the room brightness is too bright, Raspberry Pi will drive
the motor to close the curtain; when the room brightness is too dark, the curtain will be opened.
Also you can view the indoor brightness change through text widget on Cloud4RPi, or control the lamp with Switch
widget (for electricity safety, this experiment uses LED instead).
94
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 ...