#include<LiquidCrystal.h>
#include"DHT.h"
#define DHTPIN 53
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
long cnt=0;
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 1
#define CS_PIN 4
#define DATA_PIN 3
#define CLK_PIN 2
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE,DATA_PIN,CLK_PIN, CS_PIN, MAX_DEVICES);
#include <MaxMatrix.h>
int DIN = 3; // DIN pin of MAX7219 module
int CLK = 2; // CLK pin of MAX7219 module
int CS = 4; // CS pin of MAX7219 module
int maxInUse = 1;
MaxMatrix m(DIN, CS, CLK, maxInUse);
int cntde=0;
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int ledState = LOW;
unsigned long previousMillis = 0;
const float BETA = 3950;
int temp2=0;
float f=0; //tempF
float t=0; //tempC
float h=0; //humidity
void setup() {
// Intialize the LCD object:
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15):
myDisplay.setIntensity(0);
// Clear the display:
myDisplay.displayClear();
// initialize serial communication at 9600 bits per second:
//Serial.begin(19200);
lcd.begin(16,2);
dht.begin();
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
m.init(); // MAX7219 initialization
m.setIntensity(0); // initial led matrix intensity, 0-15
}
void loop() {
//Read humitidy
h = dht.readHumidity();
// Read temperature as Celsius (the default)
t = dht.readTemperature(false);
//Read temperature as Fahrenheit (isFahrenheit = true)
f = dht.readTemperature(true);
unsigned long currentMillis = millis();
int mypot=0;
float mytemp=0;
mypot=analogRead(A0); //Read pots wiper voltage as 0 to 1023 10 bit ad converter
mytemp=analogRead(A1); //read the analog tempeture sensor
// convert temp sensor voltage to degrees C
float celsius =1/ (log(1 / (1023. / mytemp - 1)) / BETA + 1.0 / 298.15) - 273.15;
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.setIntensity(0);
float voltage=mypot*(5.0/1023.0); // convert alalog steps to voltage
cnt ++;
/*Serial.print("Temperature = ");
Serial.println(f,2);
Serial.print("Humidity = ");
Serial.println(h,2);
Serial.print( "cnt ");
Serial.println(cnt);
*/
lcd.setCursor(0, 1);
lcd.print(voltage);
lcd.setCursor(6,1);
lcd.print(f);
lcd.setCursor(6, 0);
lcd.print(t);
lcd.setCursor(0, 0);
char buffer1[10];
char buffer2[20];
//celsius=(celsius*1.8)+32;
//dtostrf(celsius,4,2,buffer2);
sprintf(buffer1, "%4d", mypot); // 4 trailing spaces
lcd.print(buffer1);
lcd.setCursor(12,0); // print humitidy
lcd.print(h,1);
cntde++;
/*if (cntde>2){
m.setColumn(3,61);// ease d
cntde=0;
}
//draw arm up
m.setDot(0,3,1);
m.setDot(6,3,1);
delay(500);
//erase arm up
m.setDot(0,3,0);
m.setDot(6,3,0);
//dram arm down
m.setDot(0,5,1);
m.setDot(6,5,1);
delay(500);
//erase arm down
m.setDot(0,5,0);
m.setDot(6,5,0);
*/
//the voltage at the pots wiper detrmins the blink speed lower=faster
if (currentMillis - previousMillis >= (mypot)) {
// save the last time you blinked the LED
previousMillis = currentMillis;
if (ledState ==LOW) {
ledState = HIGH;
//myDisplay.print("H");
myprintL();
lcd.setCursor(12, 1); //Print this to lcd here to slow it down to the blink rate
lcd.print(celsius); //celsius has been convert to F }
}
else {
ledState = LOW;
//myDisplay.print("L");
myprintH();
}
}
digitalWrite(5, !ledState);
digitalWrite(6, ledState);
}
void myprintL(){
m.setColumn(7,15);
m.setColumn(6,9);
m.setColumn(5,15);
m.setColumn(4,30);//with d 61=no d 253=d
m.setColumn(3,10);
m.setColumn(2,250);
m.setColumn(1,80);
m.setColumn(0,80);
//return;
}
void myprintH(){
m.setColumn(7,0);
m.setColumn(6, 0);
m.setColumn(5,239);
m.setColumn(4,41);//with d 61=no d 253=d
m.setColumn(3,73);
m.setColumn(2,239);
m.setColumn(1,0);
m.setColumn(0,0);
}