Show Posts
|
|
Pages: [1] 2 3 4
|
|
3
|
Using Arduino / Programming Questions / Re: Can someone please test this for me?
|
on: October 17, 2012, 06:25:38 am
|
|
UPDATE: i have modified the code again. Instead of having print out statements for each SteinHart functions. I've moved all of those printouts into 1 functions. and left the rest call for each other based on the calculation on each function (e.g from SH_Kelvs to SH_Celcs can be done by calling the function when it is needed on the calculation, etc).
|
|
|
|
|
6
|
Using Arduino / Programming Questions / Can someone please test this for me?
|
on: October 17, 2012, 02:12:56 am
|
I don't have the materials to test my code out. Materials needed to test this are: = 2x LEDs = 1x Thermister = 2x Buttons = 1x Breadboards = 2x 220Ohm Resistance(for the LEDs) = 3x 10KOhm Resistance(for the Buttons and Thermister) = Cables = 1x Arduino UNO And here is my code layout for this task: - const int ThermPin = A0; const int rows = 10; const int cols = 2; const int ButtonPin = 6; const int ButtonPin1 = 7; int ButtonState = 0; int ButtonState1 = 0; const int LEDPin1 = 2; const int LEDPin2 = 3; 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);} //Displays the Lookup of the System(incl. The Value, Volt, & Resistance) int getTempLookUp(int ThermPin){ //Declares the variables float Vin = 5.0; float ThermResist = 0.0; float R2 = 10000.0; float SensorValue = 0.0; float Vout = 0.0; //Declares the variables of the ThermPin & prints out the results based on the Thermister 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");}
//Displays the Celcius based on the Array of the ThermResistance int getTempCelc(int ThermPin){ //Declares the variables float Vin = 5.0; float ThermResist = 0.0; float R2 = 10000.0; float SensorValue = 0.0; float Vout = 0.0;
//Calculates the voltage from the Sensorvalue of the Themister SensorValue = analogRead(ThermPin); Vout = (((SensorValue+1)*Vin)/1024.0); ThermResist =((R2*Vin)/Vout)-R2;
//Call out the Table Array from the index //And goes calls out the temperature values based on the ThermResistance //Came out from the Thermister and prints out the results based on Celcius 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");}}}
//Displays the Kelvins based on the Array of the ThermResistance int getTempKelv(int ThermPin){ //Declares the variables float Vin = 5.0; float ThermResist = 0.0; float R2 = 10000.0; float SensorValue = 0.0; float Vout = 0.0;
//Calculates the voltage from the Sensorvalue of the Themister SensorValue = analogRead(ThermPin); Vout = (((SensorValue+1)*Vin)/1024.0); ThermResist =((R2*Vin)/Vout)-R2; //Call out the Table Array from the index //And goes calls out the temperature values based on the ThermResistance //Came out from the Thermister and prints out the results based on Kelvins 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){ //Declares the variables float Vin = 5.0; float ThermResist = 0.0; float R2 = 10000.0; float SensorValue = 0.0; float Vout = 0.0;
//Calculates the voltage from the Sensorvalue of the Themister SensorValue = analogRead(ThermPin); Vout = (((SensorValue+1)*Vin)/1024.0); ThermResist =((R2*Vin)/Vout)-R2; //Call out the Table Array from the index //And goes calls out the temperature values based on the ThermResistance //Came out from the Thermister and prints out the results based on Farenheit 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");}}} //--------------------------------------------------------------------- //SteinHart's Style!
//Calculates the value from the Thermisters, converts it to Kelvins, and prints it out int SteinHart_Kelvs(int ThermPin){ //Declares the variables 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));}
//Calculates the values called out from the previous function, converts it to Celcius, and prints it out int SteinHart_Celcs_1(int ThermPin){ //Declares the variables float Temp = SteinHart_Kelvs(ThermPin); float Celcius = Temp - 273.15;}
//Calculates the values called out from the previous function, converts it to Farenheits, and prints it out int SteinHart_Faren(int ThermPin){ //Declares the variables float Temp = SteinHart_Celcs_1(ThermPin); float Farenheit = ((Temp *9.0) /5.0 +32.0);}
int SH_Printout(int ThermPin){ float Temp = SteinHart_Kelvs(ThermPin); float Temp_1 = SteinHart_Celcs_1(ThermPin); float Temp_2 = SteinHart_Faren(ThermPin); //Prints out the results Serial.println(); Serial.print("SH_Kelvin = "); Serial.print(Temp); Serial.print(" K");
Serial.print("\t"); Serial.print("\t SH_Celcius = "); Serial.print(Temp_1); Serial.print(" C");
Serial.print("\t"); Serial.print("\t SH_Farenheit = "); Serial.print(Temp_2); Serial.println(" F");}
void loop() { ButtonState = digitalRead(ButtonPin); ButtonState1 = digitalRead(ButtonPin1); if(ButtonState == HIGH) { SH_Printout(ThermPin); digitalWrite(LEDPin1, HIGH); delay(100); } else if(ButtonState == LOW) { digitalWrite(LEDPin1, LOW); } if(ButtonState1 == HIGH) { digitalWrite(LEDPin2, HIGH); getTempLookUp(ThermPin); getTempCelc(ThermPin); getTempKelv(ThermPin); getTempFare(ThermPin); } else if(ButtonState1 == LOW) { digitalWrite(LEDPin2, LOW); }
}
Thank you  .
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: Having issues using an LDR and a Potentiomer for my AIr Conditioning System..
|
on: October 14, 2012, 03:13:48 am
|
you have 4 LEDs...
you say My LED is blinking. Is that all of them?
I notice that when you activate teh LEDs, you also send some strings through the serial port... have you considered inspecting them to see what is happening?
Well...it technically starts with the one of them. Based on the room temperature (e.g. if its 21 C or less, the green LED is lit. Otherwise, if its above 21 C the yellow LED goes on while the green LED turns off). Yes i have. There don't seem to have any Delay statements around. Aside from the button press at the loop function...And the 4th LED doesn't concern me as much.
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Re: Having issues using an LDR and a Potentiomer for my AIr Conditioning System..
|
on: October 14, 2012, 01:40:23 am
|
//--------------------------------------------------------------------- //The Rest of My Work... int SteinHart_Celcs(int ThermPin){ ButtonState = digitalRead(ButtonPin); int SensorValue = analogRead(ThermPin); int LDRSensVal = analogRead(LDRPin); 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)); float Celcius = Temp - 273.15; if(Celcius >= 10 && Celcius <= 23){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW); digitalWrite(SpeakerPin, LOW); digitalWrite(FanPin, LOW); Serial.print("Status: Its COOOLD..D..D ");} if(Celcius >= 24 && Celcius <= 29){ digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin3, LOW); digitalWrite(SpeakerPin, LOW); digitalWrite(FanPin, LOW); Serial.print("Status: Its WARM..OK ");} if(Celcius >= 30 && Celcius <= 100){ digitalWrite(LEDPin3, HIGH); digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(SpeakerPin, HIGH); Serial.print("Status: ITs HOT..SHUT THE SYSTEM DOWN...ASAP! " );} //if statement specifically made for the fan. if(Celcius >= 27 && Celcius <= 100){ digitalWrite(FanPin, HIGH);} //if statemewnt specifically made for the button reset sequence. if(ButtonState == HIGH){ digitalWrite(SpeakerPin, LOW);} else{ ButtonState = LOW;} //if statement made for the potentiometer
//if statement made for the LDR. if(LDRSensVal <= 200 && LDRSensVal >= 0){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, HIGH);} if(LDRSensVal <= 300 && LDRSensVal >= 220){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, HIGH);} if(LDRSensVal <= 400 && LDRSensVal >= 320){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, LOW);} if(LDRSensVal <= 500 && LDRSensVal >= 420){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} if(LDRSensVal <= 1023 && LDRSensVal >= 520){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} Serial.print("LDRValue = "); Serial.print(LDRSensVal); //if statement for the potentiometer if(PotentSensVal <= 200 && PotentSensVal >= 0){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, HIGH);} if(PotentSensVal <= 300 && PotentSensVal >= 220){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, HIGH);} if(PotentSensVal <= 400 && PotentSensVal >= 320){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, LOW);} if(PotentSensVal <= 500 && PotentSensVal >= 420){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} if(PotentSensVal <= 1023 && PotentSensVal >= 520){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} Serial.print("\t Pot_LDRValue = "); Serial.print(PotentSensVal); Serial.print("\t ThermistorVal = "); Serial.print(SensorValue); Serial.print("\t Celcius = "); Serial.print(Celcius); Serial.println(" C"); }
void loop(){ ButtonState1 = digitalRead(ButtonPin1); //if Statements for the Array of buttons if(ButtonState1 == HIGH){ getTempLookUp (ThermPin); getTempCelc (ThermPin); getTempKelv (ThermPin); getTempFare (ThermPin); SteinHart_Kelvs (ThermPin); SteinHart_Celcs_1(ThermPin); SteinHart_Faren (ThermPin); delay(10);} else{ if(ButtonState1 == LOW){ SteinHart_Celcs(ThermPin);}} }
|
|
|
|
|
10
|
Using Arduino / Programming Questions / Re: Having issues using an LDR and a Potentiomer for my AIr Conditioning System..
|
on: October 14, 2012, 01:40:01 am
|
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");}
|
|
|
|
|
11
|
Using Arduino / Programming Questions / Re: Having issues using an LDR and a Potentiomer for my AIr Conditioning System..
|
on: October 12, 2012, 11:19:37 pm
|
[2]: //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 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(LDRPin, INPUT); pinMode(ButtonPin, INPUT); pinMode(ButtonPin1, INPUT); pinMode(LEDPin1, OUTPUT); pinMode(LEDPin2, OUTPUT); pinMode(LEDPin3, 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"); } 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); 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");} //--------------------------------------------------------------------- //The Rest of My Work... int SteinHart_Celcs(int ThermPin){ ButtonState = digitalRead(ButtonPin); int SensorValue = analogRead(ThermPin); int LDRSensVal = analogRead(LDRPin); 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)); float Celcius = Temp - 273.15; if(Celcius >= 10 && Celcius <= 23){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW); digitalWrite(SpeakerPin, LOW); digitalWrite(FanPin, LOW); Serial.println("Status: Its COOOLD..D..D ");} if(Celcius >= 24 && Celcius <= 29){ digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin3, LOW); digitalWrite(SpeakerPin, LOW); digitalWrite(FanPin, LOW); Serial.print("Status: Its WARM..OK ");} if(Celcius >= 30 && Celcius <= 40){ digitalWrite(LEDPin3, HIGH); digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(SpeakerPin, HIGH); Serial.print("Status: ITs HOT..SHUT THE SYSTEM DOWN...ASAP! " );} //if statement specifically made for the fan. if(Celcius >= 27 && Celcius <= 40){ digitalWrite(FanPin, HIGH);} //if statemewnt specifically made for the button reset sequence. if(ButtonState == HIGH){ digitalWrite(SpeakerPin, LOW);} else{ ButtonState = LOW;} //if statement made for the LDR. if(LDRSensVal <= 200 && LDRSensVal >= 0){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, HIGH);} if(LDRSensVal <= 300 && LDRSensVal >= 220){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, HIGH);} if(LDRSensVal <= 400 && LDRSensVal >= 320){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, LOW);} if(LDRSensVal <= 500 && LDRSensVal >= 420){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} if(LDRSensVal <= 600 && LDRSensVal >= 520){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} Serial.print("LDRSensVal = "); Serial.print(LDRSensVal); //if statements made for the Potentiometer if (PotentSensVal <= 320 && PotentSensVal >= 11){ digitalWrite(FanPin, LOW);} if (PotentSensVal <= 620 && PotentSensVal >= 321){ digitalWrite(FanPin, HIGH); delay(1500); digitalWrite(FanPin, LOW); delay(1500);} if (PotentSensVal <= 820 && PotentSensVal >= 621){ digitalWrite(FanPin, HIGH); delay(600); digitalWrite(FanPin, LOW); delay(600);} if (PotentSensVal <= 920 && PotentSensVal >= 821){ digitalWrite(FanPin, HIGH); delay(400); digitalWrite(FanPin, LOW); delay(400);} if (PotentSensVal <= 920 && PotentSensVal >= 821){ digitalWrite(FanPin, HIGH); delay(200); digitalWrite(FanPin, LOW); delay(200);} if (PotentSensVal <= 970 && PotentSensVal >= 921){ digitalWrite(FanPin, HIGH);} Serial.print("\t PotentSensVal = "); Serial.print(PotentSensVal); Serial.print("\t Celcius = "); Serial.print(Celcius); Serial.println(" C"); }
void loop(){ ButtonState1 = digitalRead(ButtonPin1); SteinHart_Celcs(ThermPin); //if Statements for the Array of buttons if(ButtonState1 == HIGH){ getTempLookUp (ThermPin); getTempCelc (ThermPin); getTempKelv (ThermPin); getTempFare (ThermPin); SteinHart_Kelvs (ThermPin); SteinHart_Celcs_1(ThermPin); SteinHart_Faren (ThermPin); delay(100);} else if(ButtonState1 == LOW){ SteinHart_Celcs(ThermPin);}
delay(100); }
Would help a bit if you explain to me how the Potentiometer is used as a calibration mechanism.
|
|
|
|
|
12
|
Using Arduino / Programming Questions / Having issues using an LDR and a Potentiomer for my AIr Conditioning System..
|
on: October 12, 2012, 11:19:24 pm
|
Ok, i am currently having this problem right now. There are two tasks where it got my confused at some points. And they mention: - [1] It should only work when the lights are on, using an LDR. And [2] Use a potentiometer as a calibration mechanism Here is the code i've implemented for those tasks: [1]: const int ThermPin = A0; const int LDRPin = A1; const int PotentPin = A2; const int SpeakerPin = 11; const int ButtonPin = 6; int ButtonState = 0; const int FanPin = 5; const int LEDPin1 = 2; const int LEDPin2 = 3; const int LEDPin3 = 4;
void setup(){ Serial.begin(9600); pinMode(LDRPin, INPUT); pinMode(ButtonPin, INPUT); pinMode(LEDPin1, OUTPUT); pinMode(LEDPin2, OUTPUT); pinMode(LEDPin3, OUTPUT); pinMode(SpeakerPin, OUTPUT); pinMode(FanPin, OUTPUT); }
int SteinHart_Celcs(int ThermPin){ ButtonState = digitalRead(ButtonPin); int SensorValue = analogRead(ThermPin); int LDRSensVal = analogRead(LDRPin); 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)); float Celcius = Temp - 273.15; if(Celcius >= 10 && Celcius <= 23){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW); digitalWrite(SpeakerPin, LOW); digitalWrite(FanPin, LOW); Serial.println("Status: Its COOOLD..D..D ");} if(Celcius >= 24 && Celcius <= 29){ digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin3, LOW); digitalWrite(SpeakerPin, LOW); digitalWrite(FanPin, LOW); Serial.print("Status: Its WARM..OK ");} if(Celcius >= 30 && Celcius <= 40){ digitalWrite(LEDPin3, HIGH); digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(SpeakerPin, HIGH); Serial.print("Status: ITs HOT..SHUT THE SYSTEM DOWN...ASAP! " );} //if statement specifically made for the fan. if(Celcius >= 27 && Celcius <= 40){ digitalWrite(FanPin, HIGH);} //if statemewnt specifically made for the button reset sequence. if(ButtonState == HIGH){ digitalWrite(SpeakerPin, LOW);} else{ ButtonState = LOW;} //if statement made for the LDR. if(LDRSensVal <= 200 && LDRSensVal >= 0){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, HIGH);} if(LDRSensVal <= 300 && LDRSensVal >= 220){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, HIGH);} if(LDRSensVal <= 400 && LDRSensVal >= 320){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, HIGH); digitalWrite(LEDPin3, LOW);} if(LDRSensVal <= 500 && LDRSensVal >= 420){ digitalWrite(LEDPin1, HIGH); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} if(LDRSensVal <= 600 && LDRSensVal >= 520){ digitalWrite(LEDPin1, LOW); digitalWrite(LEDPin2, LOW); digitalWrite(LEDPin3, LOW);} Serial.print("LDRSensVal = "); Serial.print(LDRSensVal); //if statements made for the Potentiometer if (PotentSensVal <= 320 && PotentSensVal >= 11){ digitalWrite(FanPin, LOW);} if (PotentSensVal <= 620 && PotentSensVal >= 321){ digitalWrite(FanPin, HIGH); delay(1500); digitalWrite(FanPin, LOW); delay(1500);} if (PotentSensVal <= 820 && PotentSensVal >= 621){ digitalWrite(FanPin, HIGH); delay(600); digitalWrite(FanPin, LOW); delay(600);} if (PotentSensVal <= 920 && PotentSensVal >= 821){ digitalWrite(FanPin, HIGH); delay(400); digitalWrite(FanPin, LOW); delay(400);} if (PotentSensVal <= 920 && PotentSensVal >= 821){ digitalWrite(FanPin, HIGH); delay(200); digitalWrite(FanPin, LOW); delay(200);} if (PotentSensVal <= 970 && PotentSensVal >= 921){ digitalWrite(FanPin, HIGH);} Serial.print("\t PotentSensVal = "); Serial.print(PotentSensVal); Serial.print("\t Celcius = "); Serial.print(Celcius); Serial.println(" C");
} void loop(){ SteinHart_Celcs(ThermPin); delay(100); }
Making the system only works when the lights are on using the LDR.
|
|
|
|
|
13
|
Using Arduino / Programming Questions / Re: Having trouble on solving the following tasks
|
on: October 07, 2012, 02:54:43 am
|
One last issue in that code: Serial.print("Value = "); Serial.print(SensorValue); Serial.print("\t Voltage = "); Serial.print(Vout); Serial.print(" V"); Serial.print("\t Resistance = "); Serial.print(ThermResist); Serial.println(" Ohm"); Serial.print(Table[i][0]); Serial.print("\t");
The wrong line used println() instead of print(). Thanks for the advice PaulS  .
|
|
|
|
|
15
|
Using Arduino / Programming Questions / Re: Having trouble on solving the following tasks
|
on: October 04, 2012, 11:30:04 am
|
My latest update for my code  : - const int ThermPin = A0; 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); }
void loop() {
float Vin = 5.0; float ThermResist = 0.0; float R2 = 10000.0; float SensorValue = 0.0; float Vout = 0.0; SensorValue = analogRead(ThermPin); Serial.print("Value = "); Serial.print(SensorValue); Vout = (((SensorValue+1)*Vin)/1024.0); Serial.print("\t Voltage = "); Serial.print(Vout); Serial.print(" V"); ThermResist =((R2*Vin)/Vout)-R2; Serial.print("\t Resistance = "); Serial.print(ThermResist); Serial.println(" Ohm"); for(int i; i<rows; i++) { if(ThermResist >= Table[i+1][1] && ThermResist <= Table[i][1] ) { Serial.print(Table[i][0]); Serial.print("\t"); } } }
Output: - Temperature = 25 C Value = 709.00 Voltage = 3.47 V Resistance = 4422.54 Ohm Temperature = 25 C Value = 712.00 Voltage = 3.48 V Resistance = 4361.85 Ohm Temperature = 25 C Value = 712.00 Voltage = 3.48 V Resistance = 4361.85 Ohm Temperature = 25 C Value = 717.00 Voltage = 3.51 V Resistance = 4261.84 Ohm Temperature = 25 C Value = 716.00 Voltage = 3.50 V Resistance = 4281.73 Ohm Temperature = 25 C Value = 719.00 Voltage = 3.52 V Resistance = 4222.22 Ohm Temperature = 26 C Value = 719.00 Voltage = 3.52 V Resistance = 4222.22 Ohm Temperature = 26 C Value = 723.00 Voltage = 3.54 V Resistance = 4143.65 Ohm Temperature = 26 C Value = 724.00 Voltage = 3.54 V Resistance = 4124.14 Ohm Temperature = 26 C Value = 725.00 Voltage = 3.54 V Resistance = 4104.68 Ohm Temperature = 26 C Value = 726.00 Voltage = 3.55 V Resistance = 4085.28 Ohm Temperature = 26 C Value = 728.00 Voltage = 3.56 V Resistance = 4046.64 Ohm Temperature = 26 C Value = 729.00 Voltage = 3.56 V Resistance = 4027.40 Ohm Temperature = 27 C Value = 730.00 Voltage = 3.57 V Resistance = 4008.21 Ohm Temperature = 27 C Value = 732.00 Voltage = 3.58 V Resistance = 3969.99 Ohm Temperature = 27 C Value = 733.00 Voltage = 3.58 V Resistance = 3950.95 Ohm Temperature = 27 C Value = 734.00 Voltage = 3.59 V Resistance = 3931.97 Ohm Temperature = 27 C Value = 735.00 Voltage = 3.59 V Resistance = 3913.04 Ohm Temperature = 27 C Value = 734.00 Voltage = 3.59 V Resistance = 3931.97 Ohm Temperature = 27 C Value = 737.00 Voltage = 3.60 V Resistance = 3875.34 Ohm Temperature = 27 C Value = 737.00 Voltage = 3.60 V Resistance = 3875.34 Ohm Temperature = 27 C Value = 735.00 Voltage = 3.59 V Resistance = 3913.04 Ohm Temperature = 27 C Value = 739.00 Voltage = 3.61 V Resistance = 3837.84 Ohm Temperature = 27 C Value = 739.00 Voltage = 3.61 V Resistance = 3837.84 Ohm Temperature = 27 C Value = 738.00 Voltage = 3.61 V Resistance = 3856.56 Ohm Temperature = 27 C Value = 740.00 Voltage = 3.62 V Resistance = 3819.16 Ohm Temperature = 27 C Value = 740.00 Voltage = 3.62 V Resistance = 3819.16 Ohm Temperature = 27 C Value = 741.00 Voltage = 3.62 V Resistance = 3800.54 Ohm Temperature = 27 C Value = 742.00 Voltage = 3.63 V Resistance = 3781.96 Ohm Temperature = 28 C Value = 742.00 Voltage = 3.63 V Resistance = 3781.96 Ohm Temperature = 28 C Value = 743.00 Voltage = 3.63 V Resistance = 3763.44 Ohm Temperature = 28 C Value = 743.00 Voltage = 3.63 V Resistance = 3763.44 Ohm Temperature = 28 C Value = 742.00 Voltage = 3.63 V Resistance = 3781.96 Ohm Temperature = 28 C Value = 745.00 Voltage = 3.64 V Resistance = 3726.54 Ohm Temperature = 28 C Value = 744.00 Voltage = 3.64 V Resistance = 3744.97 Ohm Temperature = 28 C Value = 745.00 Voltage = 3.64 V Resistance = 3726.54 Ohm Temperature = 28 C Value = 746.00 Voltage = 3.65 V Resistance = 3708.17 Ohm Temperature = 28 C Value = 746.00 Voltage = 3.65 V Resistance = 3708.17 Ohm Temperature = 28 C Value = 745.00 Voltage = 3.64 V Resistance = 3726.54 Ohm Temperature = 29 C Value = 759.00 Voltage = 3.71 V Resistance = 3473.68 Ohm Temperature = 29 C Value = 759.00 Voltage = 3.71 V Resistance = 3473.68 Ohm Temperature = 29 C Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm Temperature = 29 C Value = 757.00 Voltage = 3.70 V Resistance = 3509.23 Ohm Temperature = 29 C Value = 759.00 Voltage = 3.71 V Resistance = 3473.68 Ohm Temperature = 29 C Value = 759.00 Voltage = 3.71 V Resistance = 3473.68 Ohm Temperature = 29 C Value = 760.00 Voltage = 3.72 V Resistance = 3455.98 Ohm Temperature = 29 C Value = 759.00 Voltage = 3.71 V Resistance = 3473.68 Ohm Temperature = 29 C Value = 758.00 Voltage = 3.71 V Resistance = 3491.44 Ohm Temperature = 29 C Value = 760.00 Voltage = 3.72 V Resistance = 3455.98 Ohm Temperature = 29 C Value = 760.00 Voltage = 3.72 V Resistance = 3455.98 Ohm Temperature = 29 C Value = 760.00 Voltage = 3.72 V Resistance = 3455.98 Ohm Temperature = 29 C Value = 760.00 Voltage = 3.72 V Resistance = 3455.98 Ohm Temperature = 30 C Value = 769.00 Voltage = 3.76 V Resistance = 3298.70 Ohm Temperature = 29 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 770.00 Voltage = 3.76 V Resistance = 3281.45 Ohm Temperature = 29 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 770.00 Voltage = 3.76 V Resistance = 3281.45 Ohm Temperature = 29 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 772.00 Voltage = 3.77 V Resistance = 3247.09 Ohm Temperature = 30 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 772.00 Voltage = 3.77 V Resistance = 3247.09 Ohm Temperature = 30 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 772.00 Voltage = 3.77 V Resistance = 3247.09 Ohm Temperature = 30 C Value = 772.00 Voltage = 3.77 V Resistance = 3247.09 Ohm Temperature = 30 C Value = 773.00 Voltage = 3.78 V Resistance = 3229.97 Ohm Temperature = 30 C Value = 773.00 Voltage = 3.78 V Resistance = 3229.97 Ohm Temperature = 30 C Value = 773.00 Voltage = 3.78 V Resistance = 3229.97 Ohm Temperature = 30 C Value = 774.00 Voltage = 3.78 V Resistance = 3212.90 Ohm Temperature = 30 C Value = 773.00 Voltage = 3.78 V Resistance = 3229.97 Ohm Temperature = 30 C Value = 773.00 Voltage = 3.78 V Resistance = 3229.97 Ohm Temperature = 30 C Value = 772.00 Voltage = 3.77 V Resistance = 3247.09 Ohm Temperature = 30 C Value = 772.00 Voltage = 3.77 V Resistance = 3247.09 Ohm Temperature = 30 C Value = 771.00 Voltage = 3.77 V Resistance = 3264.25 Ohm Temperature = 30 C Value = 773.00 Voltage = 3.78 V Resistance = 3229.97 Ohm Temperature = 31 C Value = 775.00 Voltage = 3.79 V Resistance = 3195.88 Ohm Temperature = 31 C Value = 776.00 Voltage = 3.79 V Resistance = 3178.89 Ohm Temperature = 31 C Value = 775.00 Voltage = 3.79 V Resistance = 3195.88 Ohm Temperature = 31 C Value = 775.00 Voltage = 3.79 V Resistance = 3195.88 Ohm Temperature = 32 C Value = 780.00 Voltage = 3.81 V Resistance = 3111.40 Ohm Temperature = 32 C Value = 777.00 Voltage = 3.80 V Resistance = 3161.95 Ohm Temperature = 32 C Value = 779.00 Voltage = 3.81 V Resistance = 3128.20 Ohm Temperature = 32 C Value = 779.00 Voltage = 3.81 V Resistance = 3128.20 Ohm Temperature = 32 C Value = 777.00 Voltage = 3.80 V Resistance = 3161.95 Ohm Temperature = 32 C Value = 779.00 Voltage = 3.81 V Resistance = 3128.20 Ohm Temperature = 32 C Value = 779.00 Voltage = 3.81 V Resistance = 3128.20 Ohm Temperature = 32 C Value = 778.00 Voltage = 3.80 V Resistance = 3145.06 Ohm Temperature = 32 C Value = 778.00 Voltage = 3.80 V Resistance = 3145.06 Ohm Temperature = 32 C Value = 777.00 Voltage = 3.80 V Resistance = 3161.95 Ohm Temperature = 32 C Value = 778.00 Voltage = 3.80 V Resistance = 3145.06 Ohm Temperature = 32 C Value = 780.00 Voltage = 3.81 V Resistance = 3111.40 Ohm Temperature = 32 C Value = 782.00 Voltage = 3.82 V Resistance = 3077.91 Ohm Temperature = 33 C Value = 779.00 Voltage = 3.81 V Resistance = 3128.20 Ohm Temperature = 34 C Value = 783.00 Voltage = 3.83 V Resistance = 3061.22 Ohm Temperature = 34 C Value = 783.00 Voltage = 3.83 V Resistance = 3061.22 Ohm Temperature = 34 C Value = 782.00 Voltage = 3.82 V Resistance = 3077.91 Ohm
|
|
|
|
|