No exit from "if"
hi everybody,
could explain me why following scketch doesn't work? stupid program 3 leds , 4.7 kohm thermistor (that 1 included in workshop kit - base level).
the problem lights red led if temperature rises 22°c (green led) 23 °c (yellow led).
serial monitor gives me correct temperature red led on!!!
maybe if cycle wrong...
attached frizing sketch!
thanks
moderatore added code tags -> use # button above smileys,
could explain me why following scketch doesn't work? stupid program 3 leds , 4.7 kohm thermistor (that 1 included in workshop kit - base level).
the problem lights red led if temperature rises 22°c (green led) 23 °c (yellow led).
serial monitor gives me correct temperature red led on!!!
maybe if cycle wrong...
attached frizing sketch!
thanks
code: [select]
#include <math.h>
const int sensorpin = 1;
int sensorvalue;
int led1 = 2; //green led
int led2 = 4; //yellow led
int led3 = 7; //red led
float tensione;
float rt;
float temp;
void setup() {
pinmode (led1,output);
pinmode (led2,output);
pinmode (led3,output);
serial.begin(9600);}
void loop() {
sensorvalue = analogread(sensorpin);
tensione=4.83-((4.83*sensorvalue)/1024);
rt=20000*((4.83-tensione)/tensione);
temp = 10.5915*tensione*tensione - 55.5533*tensione + 67.3157;
serial.print(sensorvalue);
serial.print(" -> ");
serial.print(tensione);
serial.print(" -> ");
serial.print(rt);
serial.print(" (");
serial.print(temp);
serial.println(" gradi)");
if(temp <= 23);
{digitalwrite(led1, high);
digitalwrite(led2, low);
digitalwrite(led3, low);}
if(temp > 23 && temp <= 38);
{digitalwrite(led1, low);
digitalwrite(led2, high);
digitalwrite(led3, low);}
if(temp > 38);
{digitalwrite(led1, low);
digitalwrite(led2, low);
digitalwrite(led3, high);}
delay(500);
}
moderatore added code tags -> use # button above smileys,
you have never, ever seen example code "if"s written those.
examine them carefully
examine them carefully
Arduino Forum > Using Arduino > Programming Questions > No exit from "if"
arduino
Comments
Post a Comment