EasyManuals Logo

SeeedStudio Grove Series User Manual

Default Icon
51 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #47 background imageLoading...
Page #47 background image
*/
#include "TM1637.h"
#include "DHT.h"
/* Macro Define */
#define CLK 39 /* 4-digital display clock pin */
#define DIO 38 /* 4-digital display data pin */
#define BLINK_LED RED_LED /* blink led */
#define TEMP_HUMI_PIN 24 /* pin of temperature&humidity sensor */
/* Global Varibles */
TM1637 tm1637(CLK, DIO); /* 4-digital display object */
DHT dht(TEMP_HUMI_PIN, DHT22); /* temperature&humidity sensor object */
int8_t t_bits[2] = {0}; /* array to store the single bits of the temperature */
int8_t h_bits[2] = {0}; /* array to store the single bits of the humidity */
/* the setup() method runs once, when the sketch starts */
void setup() {
tm1637.init(); /* initialize 4-digital display */
tm1637.set(BRIGHT_TYPICAL); /* set the brightness */
tm1637.point(POINT_ON); /* light the clock point ":" */
dht.begin(); /* initialize temperature humidity sensor */
pinMode(RED_LED, OUTPUT); /* declare the red_led pin as an OUTPUT */
}
/* the loop() method runs over and over again */
void loop() {
int _temperature = dht.readTemperature(); /* read the temperature value from the
sensor */
int _humidity = dht.readHumidity(); /* read the humidity value from the sensor */
memset(t_bits, 0, 2); /* reset array when we use it */
memset(h_bits, 0, 2);
/* 4-digital-display [0,1] is used to display temperature */
t_bits[0] = _temperature % 10;
_temperature /= 10;
t_bits[1] = _temperature % 10;
/* 4-digital-display [2,3] is used to display humidity */
h_bits[0] = _humidity % 10;
_humidity /= 10;

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SeeedStudio Grove Series and is the answer not in the manual?

SeeedStudio Grove Series Specifications

General IconGeneral
BrandSeeedStudio
ModelGrove Series
CategoryMicrocontrollers
LanguageEnglish

Related product manuals