I've bought the arduino starter kit after wanting to work with hardware for a long time.
I've never before worked with sensors or such.
I have what I believe is a thermistor, BC547B Dropbox - 20130506_214212.jpg - Simplify your life.
I tried calculating the temperature with it, but failed.
It came with the arduino starter kit. In the book that came with the kit it says it is an TMP36, but I did not find this to be the case.
this is the best datasheet I could find http://alltransistors.com/pdfview.php?doc=bc546_bc547_bc548_bc549_bc550.pdf&dire=_fairchild_semi
the code
const int sensorPin = A0;
float baselineTemp = 20.0;
//setup 3 LEDs
void setup(){
Serial.begin(9600);
for(int pinNumber =2;pinNumber<5;pinNumber++){
pinMode(pinNumber,OUTPUT);
digitalWrite(pinNumber,LOW);
}
}
void loop(){
//read the sensor A0 value
//A0 is the output from the BC547B is connected
int sensorVal = analogRead(sensorPin);
Serial.print("sensor value: ");
Serial.print(sensorVal);
//calculate temperature
//something must be wrong here
float temperature = (sensorVal/1024.0)*215;
Serial.print(", degrees C: ");
Serial.println(temperature);
//lights go on depending on temperature
//no problem seems to be here
if(temperature<baselineTemp){
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
else if(temperature >= baselineTemp+2 && temperature < baselineTemp+4){
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
else if(temperature >= baselineTemp+4 && temperature < baselineTemp+6) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
else if(temperature >= baselineTemp+6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
delay(1);
}
serial monitor output output http://arduino.cc/forum/index.php?action=post;board=1 - Pastebin.com
It's not the thermistor I have multiple and tried them al.
It's not the sensor pin I also tried multiple.
the letters on the thermistor say:
on the flat side
BC547
B
-C27
on the other side:
K4
I really appreciate all help,
thank you