Boolean Variables


hello, have few questions variables. please understanding not experienced programmer.

i read digital input, store boolean variable.
could accomplish
code: [select]
boolean variable = digitalread(pin) or have along lines of
code: [select]
if(digitalread(pin)==high){
     boolean variable = true;
}

i thought first work because high , true both equal 1, wanted make sure. thanks!

quote
could accomplish

yes, because values returned digitalread(), high , low, correspond, value-wise, true , false.

if concerned digitalread() returning other values in future, use:
code: [select]
boolean flag = (figitalread(somepin) == high);
to set flag true when digitalread() returns high.


Arduino Forum > Using Arduino > Programming Questions > Boolean Variables


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support