And if you want to show an analogical value from analogical pin, it’s code depend on the product what you need to use.
like a Grove - Temperature and Humidity Sensor Pro, we can display its’ humdity or temperature. for example: Current humdity = 62.1% , it’ll display 0621.
[code]#include <SoftwareSerial.h>
#include <TimerOne.h>
#include “TM1637.h”
#define DHT11_PIN 14
int8_t TimeDisp[] = {0x00,0x00,0x00,0x00};
#define CLK 2
#define DIO 3
TM1637 tm1637(CLK,DIO);
byte read_dht11_dat()
{
byte i = 0;
byte result=0;
for(i=0; i< 8; i++){
while(!digitalRead(DHT11_PIN));
delayMicroseconds(30);
if(digitalRead(DHT11_PIN))
result |=(1<<(7-i));
while(digitalRead(DHT11_PIN));
}
return result;
}
void setup()
{
pinMode(DHT11_PIN,OUTPUT);
Serial.begin(9600);
tm1637.set();
tm1637.init();
}
void loop()
{
byte dht11_dat[5];
byte dht11_in;
byte i;
float humdity,temperature;
digitalWrite(DHT11_PIN,LOW);
delay(18);
digitalWrite(DHT11_PIN,HIGH);
delayMicroseconds(40);
pinMode(DHT11_PIN,INPUT);
delayMicroseconds(160);
for (i=0; i<5; i++)
dht11_dat[i] = read_dht11_dat();
pinMode(DHT11_PIN,OUTPUT);
digitalWrite(DHT11_PIN,HIGH);
humdity=((float)(dht11_dat[0]*256+dht11_dat[1]))/10;
//temperature=((float)(dht11_dat[2]256+dht11_dat[3]))/10;
Serial.print("Current humdity = “);
Serial.print(humdity,1);
Serial.print(”% ");
int Value;
Value=humdity10;
TimeDisp[3]=Value%10;
TimeDisp[2]=Value%100/10;
TimeDisp[1]=Value%1000/100;
TimeDisp[0]=Value/1000;
tm1637.display(TimeDisp);
delay(1000);
}[/code]