![Seeed Grove Скачать руководство пользователя страница 6](http://html.mh-extra.com/html/seeed/grove/grove_manual_1232889006.webp)
7/23/22, 9:41 PM
Grove - Chainable RGB LED - Seeed Wiki
https://wiki.seeedstudio.com/Grove-Chainable_RGB_LED/
6/29
21
22
return
sum>>
5
;
23
}
24
25
float
getTemp
()
// get temperature
26
{
27
float
temperature =
0.0
;
28
float
resistance =
0.0
;
29
int
B =
3975
;
//B value of the thermistor
30
31
int
a = getAnalog();
32
33
resistance = (
float
)(
1023
-a)*
10000
/a;
//get the r
34
temperature =
1
/(
log
(resistance/
10000
)/B+
1
/
298.15
35
return
temperature;
36
}
37
38
void
ledLight
(
int
dta)
// light led
39
{
40
41
dta = dta/
4
;
// 0 - 255
42
43
int
colorR = dta;
44
int
colorG =
255
-dta;
45
int
colorB =
0
;
46
47
leds.setColorRGB(
0
, colorR, colorG, colorB);
48
}
49
50
void
setup
()
51
{
52
Serial.begin(
38400
);
53
cout
<<
"hello world !"
<<
endl
;
54
}
55
56
void
loop
()
57
{
58
float
temp = getTemp();
59
int
nTemp = temp*
100
;
60
61
nTemp = nTemp > TEMPUP*
100
? TEMPUP*
100
: (nTemp