else-if sentences issue
hi,
i'm adapting thermometer code arduino uno makeymakey in order make tests have problem when working on it. code next:
where have discarded functions defined me. anyway, when type 'm' wanto change number of values used calculate mean, when type in numerical value, program jumps next else-if sentence sample period changed. don't understand what's wrong , appreciated.
i must i've been having troubles , misbehaviour sketch since working on makey, although worked arduino uno. i'm not sure if problem may in ide (it not hte latest version) sounds strange me.
i hope me. thank time.
i'm adapting thermometer code arduino uno makeymakey in order make tests have problem when working on it. code next:
code: [select]
#define analogpin 22 //23 18 pins related mouse
//the 22 1 labeled a4
#define beta 3000
#define resistance 47 //it in ohms
int lastreading=0;
boolean loggingon=false;
int period=300;
int count=0;
int span=20;
void setup() {
pinmode(ledpin, output);
pinmode(analogpin, input);
serial.begin(9600);
serial.println("listo");
}
void loop()
{
if(serial.available())
{
char ch=serial.read();
if (ch == 'g' || ch == 'g')
{
loggingon = true;
serial.println("logging started");
}
else if (ch == 'm' || ch == 'm')
{
//changes ammount of values used compute mean
serial.println("cantidad de valores promediar: ");
char newspan=serial.read();
span = newspan;
}
else if ((ch > '0') && (ch <= '9') )
{
setperiod(ch);
}
else if (ch == '?')
{
reportstatus();
}
}
if (loggingon && count>period)
{
logreading();
count=0;
}
count++;
delay(1000); //mirar en arduino.cc para usar otra cosa que no es delay
}
where have discarded functions defined me. anyway, when type 'm' wanto change number of values used calculate mean, when type in numerical value, program jumps next else-if sentence sample period changed. don't understand what's wrong , appreciated.
i must i've been having troubles , misbehaviour sketch since working on makey, although worked arduino uno. i'm not sure if problem may in ide (it not hte latest version) sounds strange me.
i hope me. thank time.
do have "no line ending" option set in serial monitor?
Arduino Forum > Using Arduino > Programming Questions > else-if sentences issue
arduino
Comments
Post a Comment