Professional Documents
Culture Documents
DHT11() is disabled
Version 1.2 with DHT11 RH, DS18B20 & Temp & secret voltmeter
Version 1.3 with 7-segment testing, blink 5 times
QA - a
QB - b
QC - c
QD - d
QE - e
QF - f
QG - g
Stanley Seow
stanleyseow@gmail.com
*/
int temp = 0;
int humid = 0;
int volt = 0;
// DHT11 setup
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);
if ( !RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
*/
// a - top bar
// b - top right
// c - bottom right
// d - bottom bar
// e - bottom left
// f - top right
// g - middle bar
g_digits [0] = a + b + c + d + e + f;
g_digits [1] = b + c;
g_digits [2] = a + b + g + e + d;
g_digits [3] = a + b + g + c + d;
g_digits [4] = f + g + b + c;
g_digits [5] = a + f + g + c + d;
g_digits [6] = a + f + g + c + d + e;
g_digits [7] = a + b + c;
g_digits [8] = a + b + c + d + e + f + g;
g_digits [9] = a + b + c + d + g + f;
g_digits [90] = a + b + g + f; // Degree dot
g_digits [91] = a + f + e + d; // Capital C
g_digits [92] = e + g; // r, 80
g_digits [93] = f + e + g + c; // h, 116
g_digits [99] = 0;
} // End of setup() //
// Simple function to send serial data to one or more shift registers by iterating
backwards through an array.
// Although g_registers exists, they may not all be being used, hence the input
parameter.
int dht11() {
byte dht11_dat[5];
byte dht11_in;
byte i;// start condition
// 1. pull-down i/o pin from 18ms
PORTC &= ~_BV(DHT11_PIN);
delay(18);
PORTC |= _BV(DHT11_PIN);
delayMicroseconds(40);
DDRC &= ~_BV(DHT11_PIN);
delayMicroseconds(40);
humid = dht11_dat[0];
temp = dht11_dat[2];
void loop()
{
int hour,minute,sec,disp = 0;
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
*/
Serial.print(hour);
Serial.print(':');
Serial.print(minute);
Serial.print(':');
Serial.print(sec);
Serial.println();
/* Disable DHT11
if ( (sec == 0) || (sec == 10) || (sec == 20) || (sec == 30) ||
(sec == 40) || (sec == 50) ) {
// Debugging to serial
Serial.print("humdity = ");
Serial.print(humid, DEC);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(temp, DEC);
Serial.println("C ");
// Push the 2 digit temp, degree symbol & Char C to the 7-segment LED
g_registerArray [0] = g_digits [temp / 10];
g_registerArray [1] = g_digits [temp % 10];
g_registerArray [2] = g_digits [90]; // Degree symbol
g_registerArray [3] = g_digits [91]; // C
// Serial debugging
Serial.println(volt, DEC );
else {
// Display time
sendSerialData (g_registers, g_registerArray);
}
} // end of loop