I don't know why but. My LED keeps on blinking at some point...
Code(so far): -
//My Global Variables
const int ThermPin = A0;
const int LDRPin = A1;
const int PotentPin = A2;
const int SpeakerPin = 11;
const int ButtonPin = 6;
const int ButtonPin1 = 7;
int ButtonState = 0;
int ButtonState1 = 0;
const int FanPin = 5;
const int LEDPin1 = 2;
const int LEDPin2 = 3;
const int LEDPin3 = 4;
const int LEDPin4 = 8;
const int rows = 10;
const int cols = 2;
int Table[rows][cols] ={ //col 0||col 1
{ 25, 4470 }, //row 0
{ 26, 4250 }, //row 1
{ 27, 4030 }, //row 2
{ 28, 3800 }, //row 3
{ 29, 3530 }, //row 4
{ 30, 3270 }, //row 5
{ 31, 3200 }, //row 6
{ 32, 3170 }, //row 7
{ 33, 3100 }, //row 8
{ 34, 3070 } //row 9
};
void setup(){
Serial.begin(9600);
pinMode(ButtonPin, INPUT);
pinMode(ButtonPin1, INPUT);
pinMode(LEDPin1, OUTPUT);
pinMode(LEDPin2, OUTPUT);
pinMode(LEDPin3, OUTPUT);
pinMode(LEDPin4, OUTPUT);
pinMode(SpeakerPin, OUTPUT);
pinMode(FanPin, OUTPUT);
}
int getTempLookUp(int ThermPin)
{
float Vin = 5.0;
float ThermResist = 0.0;
float R2 = 10000.0;
float SensorValue = 0.0;
float Vout = 0.0;
SensorValue = analogRead(ThermPin);
Serial.println();
Serial.print("LookupValue = ");
Serial.print(SensorValue);
Vout = (((SensorValue+1)*Vin)/1024.0);
Serial.print("\t");
Serial.print("\t Voltage = ");
Serial.print(Vout);
Serial.print(" V");
ThermResist =((R2*Vin)/Vout)-R2;
Serial.print("\t");
Serial.print("\t Resistance = ");
Serial.print(ThermResist);
Serial.print(" Ohm");
Serial.print("\t");
}
int getTempCelc(int ThermPin)
{
float Vin = 5.0;
float ThermResist = 0.0;
float R2 = 10000.0;
float SensorValue = 0.0;
float Vout = 0.0;
SensorValue = analogRead(ThermPin);
Vout = (((SensorValue+1)*Vin)/1024.0);
ThermResist =((R2*Vin)/Vout)-R2;
for(int i; i<rows; i++){
if(ThermResist >= Table[i+1][1] && ThermResist <= Table[i][1] ){
Serial.println();
Serial.print("Array_Celcius = ");
Serial.print(Table[i][0]);
Serial.print(" C");
Serial.print("\t");}}
}
int getTempKelv(int ThermPin)
{
float Vin = 5.0;
float ThermResist = 0.0;
float R2 = 10000.0;
float SensorValue = 0.0;
float Vout = 0.0;
SensorValue = analogRead(ThermPin);
Vout = (((SensorValue+1)*Vin)/1024.0);
ThermResist =((R2*Vin)/Vout)-R2;
for(int i; i<rows; i++){
if(ThermResist >= Table[i+1][1] && ThermResist <= Table[i][1] ){
Serial.print("\t Array_Kelvins = ");
Serial.print(Table[i][0] + 273.15);
Serial.print(" K");
Serial.print("\t");}}
}
int getTempFare(int ThermPin)
{
float Vin = 5.0;
float ThermResist = 0.0;
float R2 = 10000.0;
float SensorValue = 0.0;
float Vout = 0.0;
SensorValue = analogRead(ThermPin);
Vout = (((SensorValue+1)*Vin)/1024.0);
ThermResist =((R2*Vin)/Vout)-R2;
for(int i; i<rows; i++){
if(ThermResist >= Table[i+1][1] && ThermResist <= Table[i][1] ){
Serial.print(" Array_Farenheit = ");
Serial.print( (Table[i][0] *9.0)/ 5.0 +32.0);
Serial.print(" F");
Serial.println();}}
}
//---------------------------------------------------------------------
//SteinHart's Style!
int SteinHart_Kelvs(int ThermPin){
int SensorValue = analogRead(ThermPin);
int PotentSensVal = analogRead(PotentPin);
float C1 = 1.346e-03;
float C2 = 2.309e-04;
float C3 = 9.815e-08;
float Rt = 10000.0;
float logRt = log(((10240000/SensorValue) - Rt));
float Temp = (1.0/(C1 + C2*logRt + C3*logRt*logRt*logRt));
Serial.print("SH_Kelvin = ");
Serial.print(Temp);
Serial.print(" K");}
int SteinHart_Celcs_1(int ThermPin){
int SensorValue = analogRead(ThermPin);
float C1 = 1.346e-03;
float C2 = 2.309e-04;
float C3 = 9.815e-08;
float Rt = 10000.0;
float logRt = log(((10240000/SensorValue) - Rt));
float Temp = (1.0/(C1 + C2*logRt + C3*logRt*logRt*logRt));
float Celcius = Temp - 273.15;
Serial.print("\t");
Serial.print("\t SH_Celcius = ");
Serial.print(Celcius);
Serial.print(" C");}
int SteinHart_Faren(int ThermPin){
int SensorValue = analogRead(ThermPin);
float C1 = 1.346e-03;
float C2 = 2.309e-04;
float C3 = 9.815e-08;
float Rt = 10000.0;
float logRt = log(((10240000/SensorValue) - Rt));
float Temp = (1.0/(C1 + C2*logRt + C3*logRt*logRt*logRt));
float Celcius = Temp - 273.15;
float Farenheit = ((Celcius *9.0) /5.0 +32.0);
Serial.print("\t");
Serial.print("\t SH_Farenheit = ");
Serial.print(Farenheit);
Serial.println(" F");}