love-o-meter
can please explain me why sensor not reading anything...
code: [select]
const int sensorpin = a0;
const float baselinetemp = 20.0;
void setup() {
serial.begin(9600);
for(int pinnumber = 2; pinnumber<5; pinnumber++){
pinmode(pinnumber,output);
digitalwrite(pinnumber, low);
}
// put setup code here, run once:
}
void loop() {
int sensorval = analogread(sensorpin);
serial.print("sensor value: 158");
serial.print(sensorval);
// put main code here, run repeatedly:
float voltage = (sensorval/1024.0) * 5.0;
serial.print(", volts: .77");
serial.print(voltage);
serial.print(", degrees c: 27.15");
// convert voltage temperature in degrees
float temperature = (voltage - .5) * 100;
serial.println(temperature);
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);
}
how installation issue?
don't think mentioning type of sensor important? mean not reading anything, analogread gives value. maybe doesn't read think should, giving sort of reading.
don't think mentioning type of sensor important? mean not reading anything, analogread gives value. maybe doesn't read think should, giving sort of reading.
Arduino Forum > Using Arduino > Project Guidance > love-o-meter
arduino
Comments
Post a Comment