The Benedictus Gauge

The Benedictus Gauge reads the temperature and humidity and displays it on a 4 digit display upon sound activation.

BeginnerFull instructions provided299
The Benedictus Gauge

Things used in this project

Hardware components

Grove - Temperature Sensor
Seeed Grove - Temperature Sensor
×1
Grove 4-digit display
×1
Grove Sound Sensor
×1
EK-TM4C123GXL TM4C Tiva LaunchPad
Texas Instruments EK-TM4C123GXL TM4C Tiva LaunchPad
×1
Grove Starter Kit for LaunchPad
Seeed Grove Starter Kit for LaunchPad
×1

Software apps and online services

Energia
Texas Instruments Energia

Story

Read more

Schematics

Diagram

Code

Benedictus Gauge

C/C++
The code allows the launchpad and grove kit to display the temperature upon sound activation
#include "TM1637.h" 
#include "DHT.h"

#define SOUND_SENSOR       25             /* sound sensor pin */          
#define LED                RED_LED        /* LED pin */
#define THRESHOLD_VALUE    2000           /* sound threshold value*/  
#define LED                RED_LED        /* LED */
#define CLK                39             /* 4-digital display clock pin */
#define DIO                38             /* 4-digital display data pin */
#define TEMP_HUMI_PIN      24             /* pin of temperature&humidity sensor */

TM1637 tm1637(CLK, DIO);                  /* 4-digital display object */
DHT dht(TEMP_HUMI_PIN, DHT22);            /* temperature&humidity sensor object */
int brightness = 255;                     /* initialize brightness of the display */

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 */  
int sound_value = 0;                      /* initialize sound value */
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(LED, OUTPUT);                /* declare the LED pins as OUTPUT */
    pinMode(BLUE_LED, OUTPUT);  
    pinMode(GREEN_LED, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
    sound_value = analogRead(SOUND_SENSOR); 
    if(sound_value > THRESHOLD_VALUE)                         /* if the sound value is greater than threshold, activate the display */
    {
      int a;
      for ( a = 0; a < 10; a = a + 1 ) {
        digitalWrite(GREEN_LED, LOW);
        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;
        if (t_bits[1] >= 2){
             digitalWrite(RED_LED, brightness);
             digitalWrite(BLUE_LED, LOW);
          }
        else {
             digitalWrite(BLUE_LED, brightness);
             digitalWrite(RED_LED, LOW);
          }
        
        /* 4-digital-display [2,3] is used to display humidity */ 
        h_bits[0] = _humidity % 10;
        _humidity /= 10;
        h_bits[1] = _humidity % 10;
        
        /* show it */
        tm1637.display(1, t_bits[0]);
        tm1637.display(0, t_bits[1]);
        
        tm1637.display(3, h_bits[0]);
        tm1637.display(2, h_bits[1]);
        
      }
    } 
    else if(sound_value < THRESHOLD_VALUE)
    {
      /* display all zeros when the display is not in use */
      tm1637.display(1, 0);
      tm1637.display(0, 0);
      
      tm1637.display(3, 0);
      tm1637.display(2, 0);
    }
}

Credits

William Yao

William Yao

1 project • 0 followers
Andy Salitre

Andy Salitre

1 project • 0 followers
Andrew Xavier

Andrew Xavier

1 project • 0 followers
Benedictus Utama

Benedictus Utama

1 project • 0 followers
Joshua Dong

Joshua Dong

1 project • 0 followers

Comments

Add projectSign up / Login