All I want is a Boolean variable
i have piece of code:
any attempt compile using arduino 1.6.9 greeted
i have read variety of posts on forum, , have evans' booklet arduino programming notebook, , can't figure out how #include c++ header file (or 1 #include).
i have been unable decipher process of creating header file in arduino environment. creation of types.h results in new folder called types.h containing file types.h.ino remains steadfastly unrecognized.
in short, find myself unable such simple thing have boolean variable use flag.
it must able done.
would kind show me simple way make work in arduino language subset, or how extend subset make work.
thank you
code: [select]
void setup()
{
// initialize flag new press of button
boolean newpress = true;
// nominate port 2 sensing button state
int buttonstateport = 2;
// nominate port 13 powering led
int ledpowerport = 13;
}
void loop()
{
// loop check button press
while (newpress == true)
{
// check state (high or low) of button port
if (digitalread(buttonstateport) == high) // button pressed
{
// escape loop
newpress = false;
}
else
{
// wait while , check again
delay(10);
}
}
// assert: @ point button has been pressed , newpress false
// go on further processing
}
any attempt compile using arduino 1.6.9 greeted
code: [select]
latchingrelay:16: error: 'newpress' not declared in scope
while (newpress == true)
^
latchingrelay:19: error: 'buttonstateport' not declared in scope
if (digitalread(buttonstateport) == high) // button pressed
^
exit status 1
'newpress' not declared in scope
i have read variety of posts on forum, , have evans' booklet arduino programming notebook, , can't figure out how #include c++ header file (or 1 #include).
i have been unable decipher process of creating header file in arduino environment. creation of types.h results in new folder called types.h containing file types.h.ino remains steadfastly unrecognized.
in short, find myself unable such simple thing have boolean variable use flag.
it must able done.
would kind show me simple way make work in arduino language subset, or how extend subset make work.
thank you
define variables outside of setup or loop , they'll global.
Arduino Forum > Using Arduino > Programming Questions > All I want is a Boolean variable
arduino
Comments
Post a Comment