Created
June 14, 2020 12:35
-
-
Save EDISON-SCIENCE-CORNER/dfdd7a63d186228d3a9c4a23763d922e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//www.edisonsciencecorner.blogspot.com | |
//www.edisonsciencecorner.blogspot.com | |
//www.edisonsciencecorner.blogspot.com | |
//www.edisonsciencecorner.blogspot.com | |
#include <LedControl.h> | |
int lm35_pin = A0; | |
int DIN = 8; | |
int CS = 9; | |
int CLK = 10; | |
LedControl lc = LedControl(DIN, CLK, CS, 0); | |
byte smile[8] = {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C}; | |
byte sad[8] = {0x3C,0x42,0xA5,0x81,0x99,0xA5,0x42,0x3C}; | |
byte nuetral[8]= {0x3C,0x42,0xA5,0x81,0xBD,0x81,0x42,0x3C}; | |
void setup() { | |
lc.shutdown(0, false); //The MAX72XX is in power-saving mode on startup | |
lc.setIntensity(0, 15); // Set the brightness to maximum value | |
lc.clearDisplay(0); // and clear the display | |
Serial.begin(9600); | |
} | |
void loop() { | |
int temp_adc_val; | |
float temp_val; | |
temp_adc_val = analogRead(lm35_pin); /* Read Temperature */ | |
temp_val = (temp_adc_val * 4.88); /* Convert adc value to equivalent voltage */ | |
temp_val = (temp_val/10); /* LM35 gives output of 10mv/°C */ | |
Serial.print("Temperature = "); | |
Serial.print(temp_val); | |
Serial.print(" Degree Celsius\n"); | |
delay(1000); | |
if (temp_val<35) { | |
printByte(smile); | |
} | |
if (temp_val>35 && temp_val<40) { | |
printByte(nuetral); | |
} | |
if (temp_val>40) { | |
printByte(sad); | |
} | |
delay(1000); | |
} | |
void printByte(byte character []) { | |
int i = 0; | |
for(i = 0; i < 8; i++) { | |
lc.setRow(0, i, character[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment